Best Practice for Rules Configurations
This is more of a question for clarification as opposed to a feature request.
I am looking on guidance on best practices on setting up and implementing rules. Because my rules need to traverse the hierarchy both up and down, I would like to ensure that I implement these rules in the most efficient manner. The question is: Should I implement a rule per work item or have a single rule with both worktime methods in them? My Current Task rule looks like this:
if (self.Parent != null && self.WorkItemType == "Task")
{
var parent = self.Parent;
var children = parent.Children;
foreach (var child in children )
{
// Only get values from tasks
if (child.WorkItemType == "Task")
{
totValue += Convert.ToDouble(child["Microsoft.VSTS.Scheduling.CompletedWork"]);
remainValue += Convert.ToDouble(child["Microsoft.VSTS.Scheduling.RemainingWork"]);
}
}
// only write if there is a summed value
if (totValue > 0)
{
parent["Microsoft.VSTS.Scheduling.CompletedWork"] = totValue;
}
// only write if there is a summed value
if (remainValue > 0)
{
parent["Microsoft.VSTS.Scheduling.RemainingWork"] = remainValue;
}
}
I need to add another set of functionality for PBIs and Bugs such that some fields will be written to the tasks when the PBI or Bug is modified. I am looking to ensure that I do not get into a cyclical loop where the Task updates the Bug and then the bug updates the task. How to ensure calls do not get out of hand.
So, Is it best to have the entire operation in a single rule or create a rule for each work item?

So let me start with some information and maybe at the end this is something which should be reflected in our documentation.
My Rules of Thumb
- Execution Flow: First of all define criteria's, when the rule should not be executed (exit condition)
- One Field should be updated only by one rule
- A rule can update multiple fields
- Try to update only
selfand work items in direct relation toself, or in other words do not update work items not in relation withself. As saving the changed items will lead to a new work item update event which will be handled. This way an information can ripple up or down and that's why the exit condition is so important
When writing the Rule
- First step in rule execution is checking the exit conditions and exit if required
- Start with checking simple exit conditions before getting more complex (means first check all on
selfbefore checking any related work item, as this also means a server roundtrip to get the data)
Look here for some more advanced examples.
...to be continued
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
i just reopen it, to update documentation with this information