Tuesday, January 18, 2011

How to change status of the dynamic entity?

to change status of the dynamic entity follow these steps:

   1:  //Create a request object


   2:  SetStateDynamicEntityRequest stateRequest = new SetStateDynamicEntityRequest();


   3:  //Use string and not integer value for state. (For Lead use "Qualified" and not 2)


   4:  stateRequest.State = newState;


   5:  stateRequest.Status = newStatus;


   6:   


   7:  //Create an instance of the entity


   8:  Moniker m = new Moniker();


   9:  m.Id = entityId;


  10:  m.Name = myDynamicEntity.Name;


  11:   


  12:  //Set the state. Well... set the entity.


  13:  stateRequest.Entity = m;


  14:   


  15:  //Send the request


  16:  SetStateDynamicEntityResponse res = (SetStateDynamicEntityResponse)_crmService.Execute(stateRequest);


No comments: