Plugin Code to Deactivate Entity Record – MS CRM 2011

Deactivate Entity Record

You can use below code at any Condition.



EntityReference MonikerEntityEntity = new EntityReference();
MonikerEntityEntity.LogicalName = entity.LogicalName;
MonikerEntity.Id = entity.Id;

OrganizationRequest request = new Microsoft.Xrm.Sdk.OrganizationRequest() { RequestName = “SetState” };
request[“EntityMonikerEntity”] = MonikerEntity;
OptionSetValue state = new OptionSetValue(1);
OptionSetValue status = new OptionSetValue(2);
request[“State”] = state;
request[“Status”] = status;

catch (Exception)





Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s