SetState for CustomEntity in CRM

For every new custom entity created in CRM corresponding SetStateCustomEntityNameRequest and SetStateCustomEntityNameResponse class gets created which we can use to set their status.

 

In the below example we have set the status inactive for our custom country entity records.

 

 

 SetStateNew_CountryRequest myCountryRequest = new SetStateNew_CountryRequest();

                // guid of the record to be deactivated

                myCountryRequest.EntityId = new Guid(“3AE10D22-60E4-DD11-9D85-00164145E126”);

                // statecode – 1 , statecodename- Inactive, statuscode – 2, statuscodename – Inactive

                // statecode – 0 , statecodename- Inactive, statuscode – 1, statuscodename – Inactive

                myCountryRequest.New_CountryState = New_CountryState.Inactive;

                myCountryRequest.New_CountryStatus = 2;

                SetStateNew_CountryResponse myCountryResponse = (SetStateNew_CountryResponse)crmService.Execute(myCountryRequest);

 

Bye ..


Author: Nishant Rana

I love working in and sharing everything about Microsoft.NET technology !

3 thoughts on “SetState for CustomEntity in CRM”

  1. Hi Nishant
    EntityId which you are using in this record is of Individual record or of Account Entity as a whole.

    My requirement is to inactivate records based on some criterion.

    Like

Share your thoughts

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