Change State of record using Plugin in Dynamics 365 CE
To Change record status of dynamics 365 records use below code. Update your code accordingly to suit your business need.
public void UpdateState(IOrganizationService service)
{
//Update Status as Completed.
SetStateRequest setStateRequest = new SetStateRequest()
{
EntityMoniker = new EntityReference
{
Id = "<Your entityrecordid>",
LogicalName = "<EntityLogicalname>",
},
State = new OptionSetValue(1),
Status = new OptionSetValue(5)
};
_serviceProxy.Execute(setStateRequest);
}
}
Hope this helps.
Follow my blog for more trending topics on Dynamics 365, Azure, C#, Power Portals and Power Platform. For training, Courses and consulting, call to us at +91 832 886 5778 I am working more for community to share skills in Dynamics 365 and Power Platform. Please support me by subscribing my YouTube Channel. My YouTube Channel link is this : https://www.youtube.com/user/sppmaestro