Optionset
For getting the option set value:int value = ((OptionSetValue)entity["attributename"]).Value;
For getting the option set text:
string text = entity.FormattedValues["attributename"].ToString();
LookUp
For assigning the lookup value:entity["attributename"] = new EntityRefrence(entity.LogicalName,entity.Id);
eg: to set Account lookup in Opportunity
oppty["accounted"] = new EntityRefrence("account".account.Id);
For getting the lookup value:
Guid value = ((EntityRefrence)entity.Attributes["attributename"]).Id;
For getting the lookup text:
string text = ((EntityRefrence)entity.Attributes["attributename"]).Name;
No comments:
Post a Comment