Please wait, loading...

 

Activate / Deactivate a record using c# in MS CRM 2011 , MS CRM 2013 , MS CRM 2015 ( using SetStateRequest )

February 25, 2015

hey , as we offensively get requirement to activate and reactivate a record then we start using update event , but there is a very simple method to do so , by using SetStateRequest : it require an assembly ” microsoft.crm.sdk.proxy.dll ” and using ” using Microsoft.Crm.Sdk.Messages;” .
Code will be :
   SetStateRequest req = new SetStateRequest();
//the entity you want to change the state of
req.EntityMoniker = new EntityReference("new_abc", recordId);
//what should the new state be
req.State = new OptionSetValue(1);
//Pick an option from the status reason picklist to specify reason for state change
req.Status = new OptionSetValue(2);
SetStateResponse resp = (SetStateResponse)service.Execute(req);

SOURCE : JUST2CODE.IN Subscribe to our YouTube channel : https://www.youtube.com/user/TheRussell2012

https://i0.wp.com/microsoftdynamics.in/wp-content/uploads/2020/04/Microsoftdynamics365.png?fit=640%2C651
Microsoft Dynamics Community Profile

Learn more