Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 46379

How to get field name which is related to contact from each entity in dynamics crm using c#

$
0
0

Hi,

I have one function which gets data as per module name related to contacts.

Code:

if (modulename == "lead" || modulename == "opportunity")
{
	contactfield= "parentcontactid";
}
else if (modulename == "salesorder" || modulename == "quote" || modulename == "invoice")
{
	contactfield= = "customerid";
}
else
{
}


quotequery = new QueryExpression()
{
	Distinct = false,
	EntityName = modulename,
	ColumnSet = new ColumnSet(true),
	Criteria =
	{
		Filters = 
		{
			new FilterExpression
			{
				FilterOperator = LogicalOperator.And,
				Conditions = 
				{
					new ConditionExpression("ownerid", ConditionOperator.Equal, userid),                                
					new ConditionExpression(contactfield, ConditionOperator.Equal, lstcredential.Contactid.ToString())                                                  
				},
			}           
		}
	}
};
 queryentityCollection = _serviceProxy.RetrieveMultiple(quotequery).Entities;


But for all module there is different different name which is related to contact.for e.g.in lead it is parentcontactid but for invoice it is customerid.

So Is there any solution for fetch attribute name related to contact from entity name?because if else for each entity is not solution as I do in starting.

Please suggest me answer.


Viewing all articles
Browse latest Browse all 46379

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>