mercoledì 9 maggio 2012 12:40
I have a plugin that is registered on both these messages for a serviceappointment on prevalidation so that a code executes whenever the serviceappointment gets closed.
Sometimes the plugin gets called twice in the same minute for the same record.
Is it possible because the plugin is registered on both these messages that this double call happens?
Tutte le risposte
mercoledì 9 maggio 2012 13:39
mercoledì 9 maggio 2012 13:55I'm pretty sure that there isn't other code triggering the SetState. I also read a post that recommends registering on both messages, but wanted to ask here just in case anyone knew of a situation when this happens.
mercoledì 9 maggio 2012 16:11
It sounds simliar to an issue you can get on an Update plugin message.
You can add the below at the start of your code and this may get round this, as this works on the Update message.
if (context.depth <= 1)
//Execute main plugin logic
mercoledì 9 maggio 2012 21:07
While the SetState and SetStateDynamicEntity message should not get fired at the same time, there could be a scenario of when that could happen.
One would be if you Deactivate a parent record, all the child record will get triggered. When this happen, the SetState / SetStateDynamicEntity will get triggered on both parent and child records.
In the event of this, the best way is to check for the context.PrimaryEntityName to ensure it matches the entity name that you want your logic to run on.
Hope this helps.
Dimaz Pramudya - CRM Developer - CSG (Melbourne) www.xrmbits.com http://twitter.com/xrmbits