Answered by:
SetStatus Request for an Entity in CRM2011

Question
-
Hi, I am looking for an approach to set some additional attribute values on a given record (e.g. Account) when changing the status of the record.
I am familiar with the SetStateRequest approach in CRM2011. But I could not find how to set the additional attribute values when changing the record status.
Please assist. Thanks
Wednesday, December 14, 2011 1:12 PM
Answers
-
Hi,
I believe you will be changing the status through normal Deactivate/Activate (through web interface) process. which means you can register a plugin against Account entity and on SetState & SetStateDynamicEntity messages, and on the Post-Operation stage. On this plugin you can build your logic to update the additional attributes and update the record, also use can use Pre-Image get previous values as well.
Now, if you are updating through directly using your code, then you need to do two different update call, one to update status using , and then another update call to update other attributes.
//Update Status SetStateRequest setStateRequest = new SetStateRequest() { EntityMoniker = new EntityReference { Id = taskId, LogicalName = Task.EntityLogicalName, }, State = new OptionSetValue((int)TaskState.Completed), Status = new OptionSetValue(5) }; _serviceProxy.Execute(setStateRequest);
Thomas T(MCBMSS) If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".- Proposed as answer by Thomas Thankachan Wednesday, December 14, 2011 1:58 PM
- Marked as answer by SP22403 Wednesday, December 14, 2011 2:45 PM
Wednesday, December 14, 2011 1:57 PM
All replies
-
Hi,
I believe you will be changing the status through normal Deactivate/Activate (through web interface) process. which means you can register a plugin against Account entity and on SetState & SetStateDynamicEntity messages, and on the Post-Operation stage. On this plugin you can build your logic to update the additional attributes and update the record, also use can use Pre-Image get previous values as well.
Now, if you are updating through directly using your code, then you need to do two different update call, one to update status using , and then another update call to update other attributes.
//Update Status SetStateRequest setStateRequest = new SetStateRequest() { EntityMoniker = new EntityReference { Id = taskId, LogicalName = Task.EntityLogicalName, }, State = new OptionSetValue((int)TaskState.Completed), Status = new OptionSetValue(5) }; _serviceProxy.Execute(setStateRequest);
Thomas T(MCBMSS) If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".- Proposed as answer by Thomas Thankachan Wednesday, December 14, 2011 1:58 PM
- Marked as answer by SP22403 Wednesday, December 14, 2011 2:45 PM
Wednesday, December 14, 2011 1:57 PM -
Thanks Thomas. That worked.Wednesday, December 14, 2011 2:46 PM