Plugin Code to Deactivate Entity Record – MS CRM 2011

Deactivate Entity Record

You can use below code at any Condition.

try

{

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;

Service.Execute(request);
}
catch (Exception)
{

throw;
}

 

Cheers,

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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