Wednesday, September 17, 2014

Retrieve MS CRM fields using late bound

In this post I am going to Show how can we fetch value from different data type fields.

Entity _Account = service.Retrieve(“account”, new Guid(“XXXXX”), new ColumnSet(new string[] { “name”, “accountcategorycode”, “new_collectiondate”, “creditlimit”, “parentaccountid”, “new_executivecommission”, “new_isbilled” }));

//To fetch string value
string Name = _Account["name"].ToString();

//To fetch optionset selected value
int OptionSetValue = ((OptionSetValue)_Account["accountcategorycode"]).Value;

//To fetch date time field value
DateTime CollectionDate = ((DateTime)_Account["new_collectiondate"]).Date;

//To fetch money field value
decimal Creditlimit = ((Money)_Account["creditlimit"]).Value;

//To fetch decimal field value
decimal Executivecommission = (decimal)_Account["new_executivecommission"];

//To fetch lockup field
Guid ParentAccountID = ((EntityReference)_Account["parentaccountid"]).Id;

//To fetch Boolean field

Boolean IsBilled=(Boolean)_Account["new_isbilled"];

No comments:

Post a Comment

Get files of last hour in Azure Data Factory

  Case I have a Data Factory pipeline that should run each hour and collect all new files added to the data lake since the last run. What is...