Answered by:
Workflow and plugins CRM Web Service problem

Question
-
Hi,
I have two plugins in the incident entity.
The two plugins need to update the entity incident.
Each plugin runs in its time and performs its function.
At the same entity incident I have a workflow that is triggered every time a field in the entity is changed.
The problem is that this workflow is running twice and has since run up to three times. I believe it is because the plugins have to give an update on the entity.
But in none of the plugins, I change the value of this field that the workflow case.
I think when the web service provides an update on the entity, the workflow "means" that is a change and then is fired.
But the question is how to prevent this from happening?
Plugins is synchronously and wokflow asynchronously.
I wonder if there is a way in the plugin or in the CRM perhaps to inform the workflow that it should only run once.
Could anyone help me?Sunday, January 3, 2010 10:24 PM
Answers
-
Hi there
In your workflow, instead of making it trigger when "any" attribute changes, select the few attributes you want to monitor, this way when your plugin changes values it will not trigger the workflow unless it is an attribute you're monitoring.
You can do the same with your plugin, if your plugin is monitoring the "Update" event make sure you check the parameters passed into it.
XrmLinq - LINQ to Dynamics CRM http://www.xrmlinq.com - The smart way to query crm- Marked as answer by Fernanda Sousa Monday, January 4, 2010 6:26 PM
Sunday, January 3, 2010 11:12 PM -
If you update an entity in code using the Update method (or UpdateRequest), then any attributes which have a value in the BusinessEntity that is passed to the Update method will be considered by CRM to have changed. It is your responsibility to ensure that the BusinessEntity you pass to the Update method only contains values in the primary key attribute and those attributes that you are explicitly changing.
Microsoft CRM MVP - http://mscrmuk.blogspot.com http://www.excitation.co.uk- Proposed as answer by DavidBerryMVP, Moderator Monday, January 4, 2010 5:40 PM
- Marked as answer by Fernanda Sousa Monday, January 4, 2010 6:26 PM
Monday, January 4, 2010 3:04 PMModerator
All replies
-
Hi there
In your workflow, instead of making it trigger when "any" attribute changes, select the few attributes you want to monitor, this way when your plugin changes values it will not trigger the workflow unless it is an attribute you're monitoring.
You can do the same with your plugin, if your plugin is monitoring the "Update" event make sure you check the parameters passed into it.
XrmLinq - LINQ to Dynamics CRM http://www.xrmlinq.com - The smart way to query crm- Marked as answer by Fernanda Sousa Monday, January 4, 2010 6:26 PM
Sunday, January 3, 2010 11:12 PM -
Hi Amanda!
Thanks for your reply!But I'm already doing so. The workflow is only triggered when a specific field is changed, it monitors this attribute.
And none of the plugins change the value of this field, it is not used in the plugin.I was wondering if when I update the entity by the plugin if somehow the web service updates all attributes of the entity, even though the value remains the same.
It's possible?
Anyway, thank you.- Marked as answer by Fernanda Sousa Monday, January 4, 2010 6:26 PM
- Unmarked as answer by Fernanda Sousa Monday, January 4, 2010 6:26 PM
Monday, January 4, 2010 11:27 AM -
If you update an entity in code using the Update method (or UpdateRequest), then any attributes which have a value in the BusinessEntity that is passed to the Update method will be considered by CRM to have changed. It is your responsibility to ensure that the BusinessEntity you pass to the Update method only contains values in the primary key attribute and those attributes that you are explicitly changing.
Microsoft CRM MVP - http://mscrmuk.blogspot.com http://www.excitation.co.uk- Proposed as answer by DavidBerryMVP, Moderator Monday, January 4, 2010 5:40 PM
- Marked as answer by Fernanda Sousa Monday, January 4, 2010 6:26 PM
Monday, January 4, 2010 3:04 PMModerator -
Thank you David for reply!
I could solve my problem.
The problem was when publish the plugin, I'm using PostImages and was passing all the attributes of the entity.
Thank you all for your help.Monday, January 4, 2010 6:26 PM