Tuesday, February 28, 2012

Using SetStateRequest to deactivate Contact record.

Recently I wintered to deactivate contact entity for some scenarios. below is the piece of code which I used to do it so.



public void DeactivateContact(Guid contactId)
{
try
{
SetStateRequest setStateRequest = new SetStateRequest();
setStateRequest.State = new OptionSetValue(0);
setStateRequest.Status = new OptionSetValue(1);
setStateRequest.EntityMoniker = new EntityReference(Contact.EntityLogicalName, contactId);

service.Execute(setStateRequest);
}
catch (Exception exception)
{
throw exception;
}
}

No comments:

Post a Comment

MS CRM 2011 KB Article customization Issue.

Recently I have encountered some issue while customizing Kb Article Entity. I was doing following configuration in Article form. 1. Add Ba...