Try Microsoft Edge
A fast and secure browser that's designed for Windows 10
I'm having a question regarding SetState & SetStateDynamicEntity mesagges, I've been searching on blogs but I don't really understand what's the difference. What I found is that if you register a plugin in SetState you have to also register another one in SetStateDynamicEntity. Another thing is that SetStateDynamicEntity uses EntityMoniker and SetStateRequest as a difference to normal plugins(Target & Service.Update), but what I would like to understand is why we have to register the plugin in both messages and which one will be called if in different scenarios(for example if I Activate an Account thorough the view or through the Form)
Thanks in advance.
They both do the same thing but diffrently
There are multiple messages that perform the same action in CRM. One such example is SetStateRequest and SetStateDyanmicEntityRequest . If you want to write a plug-in on SetState, then you need to register it on both messages.
Check the below post that explains this in detail..
Even though it says crm 4.0 it applies to crm 2011/2013/2015.
Unfortunately, there is no good reason for having 2 messages. My understanding is that SetStateDynamicEntity is only used for legacy code written for the CRM 4 endpoint; however some internal CRM functions used to use this.
There is no definitive list of which actions cause which method, so the safest option is to jut register on both messages, and write the code to cope with the different sets of InputParameters
Hi Crm user,
I haven't confirmed this, but I was always told that SetState and SetStateDynamicEntity are different because one is run if you change the state through the CRM browser, while the other runs if you change the state through the SDK.
Hope this helps! I'd appreciate if you'd mark any helpful answers as Verified.
Thanks for your answer guys.
Aiden, with SDK you mean Plugins/Code workflows?
Another question, SetState would be for browser and SetStateDynamicEntity for SDK?
Yes, my understanding was that an SDK call using SetStateRequest would use one and clicking the Deactivate button in CRM would use the other. In either case you would want the same logic to run, so that's why you would register on both methods.
I have registered a plugin on both SetState and SetStateDynamicEntity.
But when I change the state through CRM browser or SDK, every time I found SetStateDynamicEntity message in the plugin, never got message
Let me know if I am wrong.
Did you got any info.
Yup it is always SetStateDynamicEntity either we do through browser or through SDK. I was trying it for incident entity in Dynamics 365.
I haven't use SetStateDynamicEntity & SetState and instead always preferred to write it for update message and use attribute filtering for statecode & statuscode field. I also ensure that the I have logic within the plugin code to return if the target entity doesn't contains the statecode & statuscode.
// Check we are in the process of completing
// Status is not changing
if (!entity.Attributes.Contains(phonecall.statuscode)) return;
if (entity.ReadAttributeOptionSetValue(phonecall.statuscode, (int)decimal.Zero) != 2)
Hope this helps.
Business Applications communities