How to trigger crm plugin when business process flow is set to finished ? and how to capture details (like BPF Guid) of the business process flow which is moved to finished using crm plugin ?
*This post is locked for comments
How to trigger crm plugin when business process flow is set to finished ? and how to capture details (like BPF Guid) of the business process flow which is moved to finished using crm plugin ?
*This post is locked for comments
I see, in that case you can't use a custom workflow as you require pre-state information. Given this requirement you may have use a combination of client-side scripting triggering your custom workflow.
I would start but creating a new Javascript resource, and add an event handler to stage change.
Xrm.Page.data.process.addOnStageChange(handler);
Then have this event handler populate the GUID of the BPF to an attribute. Then finally execute a page save request.
Xrm.Page.data.entity.save();
Set your custom plugin to filter on update of this new attribute. Hopefully i'm reading your query properly.
Hi Andrew,
Thank you for quick reply.
My requirement is something diff in your suggested approach you have mentioned that to create workflow and then executing custom workflow based on that. But in that case i need to create workflow on all the worflow entity and that is customization which is not allowed in publishing guideline.
Also i need some information based on pre state of the event and perform some operations on the same.
To achieve this i have created one plugin class which will execute on state change event (SetState & SetstateDynamic message) And i am able to trigger plugin on the same but now point is how to capture information of the workflow on which that plugin is triggered using EntityMoniker ?
Please suggest the solution for the same.
I would convert the plugin to a custom workflow, then create an on-demand workflow process that fires the custom workflow. Once the on-demand workflow has been created you can edit the BPF and trigger it at exit/entry to a stage.
As for passing in the ID for the BPF, I don't believe that this information gets passed to plugins/workflow as it's not an attribute belonging to the entity for which the operation is being performed. It is however supported through client side script. You could try to persist this value through client side JavaScript, capturing the ID using the following code:
var processId = procObj.getId();
(See [View:https://msdn.microsoft.com/en-au/library/dn817878.aspx] for more details on the Xrm.Page.data.process library)
Then setting this value to a custom attribute on the entity. That should work without problems.
Regards
Andrew
> If you found this answer helpful please support our community by marking as verified answer <
André Arnaud de Cal...
292,516
Super User 2025 Season 1
Martin Dráb
231,409
Most Valuable Professional
nmaenpaa
101,156