How to trigger a workflow only when a specific property is updated ?
I'm struggling with workflows on update of an item that trigger for every possible update even when Nothing relevant for my scenario has updated. How can I trigger the workflow on updates of a specific property only ?
Best Answer
-
Jeff_Lang Customer Ninja IT Monkey ✭✭✭✭to have it pick up any change to a specific field, you would need to edit the management pack, i've found the easiest way to do this is to put a check in on the property you want to check for changes, say for example i want it to run whenever the title of a service request is changed. i would setup the changed from only and add the title field, and any text eg "Title changed". then export the management pack and do a search for "Title Changed" in it and you will find something like
<Expression><br> <SimpleExpression><br> <ValueExpression><br> <Property State="Pre">$Context/Property[Type='CustomSystem_WorkItem_Library!System.WorkItem']/Title$</Property><br> </ValueExpression><br> <Operator>Like</Operator><br> <ValueExpression><br> <Value>%Title Changed%</Value><br> </ValueExpression><br> </SimpleExpression><br></Expression><br><br>
to modify the above so that it works on any update to the title field, ensure the Operator is set to NotEqualthen copy the <Property state="pre" line, and replace the <Value> line with it. on the line you just replaced change the "Pre" to "Post" and you should end up with something like
re-import the management pack, and it should now work on any update where the title before the update is not the same as the title after the update<code> <Property State="<b>Post</b>">$Context/Property[Type='CustomSystem_WorkItem_Library!System.WorkItem']/Title$</Property><br>
</ValueExpression>
</SimpleExpression>
</Expression>
</code><code><Expression><br> <SimpleExpression><br> <ValueExpression><br> <Property State="Pre">$Context/Property[Type='CustomSystem_WorkItem_Library!System.WorkItem']/Title$</Property><br> </ValueExpression><br> <Operator><b>NotEqual</b></Operator><br> <ValueExpression><br>NOTE: this will prevent you from updating the criteria again in the console, depending on the changes you do this way the fields in the console will be disabled, or if they are enabled you should not use them as that would then override what was changed manually in the management pack.5
Answers
Next question, I generally try to stay far away from touching a management pack, but I guess for my scenario there will be no alternative. What are the end to end steps to edit and update a management pack as described ? I'm assuming putting these in a separate MP would be a good idea ?
Affected User [Domain User or Group]User Name does not equal Post