Showing posts with label MS CRM plugin. Show all posts
Showing posts with label MS CRM plugin. Show all posts

Wednesday, September 23, 2015

How to set the OptionSet value in Plugin

Entity opp = new Entity("opportunity");
opp ["name"] = "Test Opportunity";      // string
opp ["estimatedclosedate"] = new DateTime(2015, 12, 1);              // DateTime
opp ["discountpercentage"] = 0.5;                                   // decimal
opp ["closeprobability"] = 82;                                       // int
opp ["isrevenuesystemcalculated"] = false;                           // bool 


Here is how we would set special field values in Dynamics CRM 2011. 
These include OptionSetValue, Money (Currency), and EntityReference (Lookup).
Entity opp = new Entity("opportunity");
opp["opportunityratingcode"] = new OptionSetValue(2);               // OptionSetValue
opp["estimatedvalue"] = new Money(700.2M);                          // Money
opp["campaignid"] = new EntityReference("campaign", campaignId);