//Create a request object
SetStateDynamicEntityRequest stateRequest = new SetStateDynamicEntityRequest();
//Use string and not integer value for state. (For Lead use "Qualified" and not 2)
stateRequest.State = newState;
stateRequest.Status = newStatus;
//Create an instance of the entity
Moniker m = new Moniker();
m.Id = entityId;
m.Name = myDynamicEntity.Name;
//Set the state. Well... set the entity.
stateRequest.Entity = m;
//Send the request
SetStateDynamicEntityResponse res = (SetStateDynamicEntityResponse)_crmService.Execute(stateRequest);
Pretty simple, huh?
For a complete list of state and status values take a look in the SDK. You should find an enumeration for every built-in entity state together with allowed status reasons.
The name should be
Of course you can use strong typed entities: (but I prefer dynamic ones)
lead myLead = new lead();
Status statusCode = new Status();
statusCode.Value = 3;
myLead.statecode = LeadState.Qualified;
myLead.statuscode = statusCode;
1 comment:
Hi.
Can you elaborate on how to get the values for Status and State when using a dynamic entity.
Thanks
Post a Comment