Monday, October 3, 2011

Inactive Account Record in CRM2011

When you need to inactive the record it is enough to include the following code
public void InactiveAccountStatus(Guid memberId)
{
      SetStateRequest setStateRequest = new SetStateRequest()
      {
           EntityMoniker = new EntityReference
           {
                 Id = memberId,
                 Name = "Account",
                 LogicalName = Account.EntityLogicalName
           },
                
           State = new OptionSetValue(AccountState.Inactive),
           Status = new OptionSetValue(2)
       };
       accountService.ServiceProxy.Execute(setStateRequest);
     }
}

Following table contain the status values 

LogicalName
Type
OptionValue
OptionDescription
statecode
State
0
Open

State
1
Closed

State
2
Canceled

State
3
Scheduled


0 comments:

Post a Comment