Inactivate, Activate in CRM 2011: using pure OrganizationRequest

Samething here, you need to add the below line to the  class “public partial class OrganizationRequest” in your Reference.cs file.

[System.Runtime.Serialization.KnownTypeAttribute(typeof(OptionSetValue))]

Then you can use the below code to activate, inactive with pure “OrganizationServiceClient” call.

 

Inactivate :

OrganizationRequest _objInactivate = newOrganizationRequest() { Parameters = newParameterCollection(), RequestName = “SetState”};

_objInactivate.Parameters.Add(new KeyValuePair<string, object>(“EntityMoniker”, newEntityReference() { Id = “guid of the account record”, LogicalName = “account”}));

_objInactivate.Parameters.Add(new KeyValuePair<string, object>(“State”, newOptionSetValue() { Value = 1 } ));

_objInactivate.Parameters.Add(new KeyValuePair<string, object>(“Status”, newOptionSetValue() { Value = 2 }));

(OrganizationServiceClient object).Execute(_objInactivate);

 

Activate:

OrganizationRequest _objActivate = new OrganizationRequest() { Parameters = new ParameterCollection(), RequestName = “SetState”};

_objActivate.Parameters.Add(new KeyValuePair<string, object>(“EntityMoniker”, new EntityReference() { Id = “guid of the account record”, LogicalName = “account”}));

_objActivate.Parameters.Add(new KeyValuePair<string, object>(“State”, newOptionSetValue() { Value = 0 }));

_objActivate.Parameters.Add(new KeyValuePair<string, object>(“Status”, newOptionSetValue() { Value = 1 }));

(OrganizationServiceClient object).Execute(_objActivate);

 

regards

joon

Advertisements

About Joon
quite ordinary man

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

%d bloggers like this: