Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent event trigger from within rule causing the event #276

Closed
jdshkolnik opened this issue Feb 20, 2018 · 2 comments
Closed

Prevent event trigger from within rule causing the event #276

jdshkolnik opened this issue Feb 20, 2018 · 2 comments

Comments

@jdshkolnik
Copy link

Hi,

Below code is based on scrum template where epic can have one or more feature children. If a feature is updated, it will aggregate effort for all of its parent epic's children which, in turn, will trigger the epic's rule to aggregate effort of all its children. Is there any way to bypass/suppress the second trigger? The parent's rule is necessary as a workaround to being unable to respond to deleted children (#275) but I imagine it'd be handy in other cases as well.

  <rule name="RollupEpics" changes="New,Change,Restore" appliesTo="Epic"><![CDATA[
    if (self.HasChildren())
    {
        self["Microsoft.VSTS.Scheduling.Effort"] = self.Children.Where(req => req["System.State"].ToString() != "Removed").Sum(req => req.GetField<double>("Microsoft.VSTS.Scheduling.Effort", 0d));
    }
    ]]></rule>
  
  <rule name="RollupFeatures" changes="New,Change,Restore" appliesTo="Feature"><![CDATA[
    if (self.HasParent())
    {
        var parent = self.Parent;
        
        if (parent.TypeName == "Epic")
        {
            parent["Microsoft.VSTS.Scheduling.Effort"] = parent.Children.Where(req => req["System.State"].ToString() != "Removed").Sum(req => req.GetField<double>("Microsoft.VSTS.Scheduling.Effort", 0d));
        }
    }
    
    if (self.HasChildren())
    {
        self["Microsoft.VSTS.Scheduling.Effort"] = self.Children.Where(req => req["System.State"].ToString() != "Removed").Sum(req => req.GetField<double>("Microsoft.VSTS.Scheduling.Effort", 0d));
    }
    ]]></rule>
@jessehouwing
Copy link
Collaborator

jessehouwing commented Feb 20, 2018 via email

@jessehouwing
Copy link
Collaborator

jessehouwing commented Feb 21, 2018

Worst case you will recalculate the value, try to store it, we will detect that no real changes occurred and we'll skip the save. This will not cause you to end endless loops.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants