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

Question : Intermediate save #208

Closed
ghost opened this issue Nov 23, 2020 · 2 comments
Closed

Question : Intermediate save #208

ghost opened this issue Nov 23, 2020 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@ghost
Copy link

ghost commented Nov 23, 2020

I try migrate rule from the old Aggregator plugin. This rule aggregate effort from children to parent.

When a item has children, the effort fields is read only by custom Hosted XML process rule (fields["MyOrg.HasChildren"] == "true").

The Aggregator rule is 3 step

  1. Set the field "MyOrg.HasChildren" to empty
  2. Set effort value
  3. Set the field "MyOrg.HasChildren" to true

This is the old rule :

//Step 1
parent["MyOrg.HasChildren"] = string.Empty; //Disable readonly on effort fields
//Step 2
parent["Microsoft.VSTS.Scheduling.CompletedWork"] = parent.Children.Sum(task => task.GetField<double>("Microsoft.VSTS.Scheduling.CompletedWork", 0d));
parent["Microsoft.VSTS.Scheduling.RemainingWork"] = parent.Children.Sum(task => task.GetField<double>("Microsoft.VSTS.Scheduling.RemainingWork", 0d));
parent["Microsoft.VSTS.Scheduling.OriginalEstimate"] = parent.Children.Sum(task => task.GetField<double>("Microsoft.VSTS.Scheduling.OriginalEstimate", 0d));
//Step 3
parent["MyOrg.HasChildren"] = parent.Children.Any().ToString(); // Enable readonly on effort fields

I write this rule to Aggregator CLI :

//Step 1
parent["MyOrg.HasChildren"] = "";
//Step 2
parent["Microsoft.VSTS.Scheduling.CompletedWork"] = parent.Children.Sum(c => c.GetFieldValue<double>("Microsoft.VSTS.Scheduling.CompletedWork", 0d));
parent["Microsoft.VSTS.Scheduling.RemainingWork"] = parent.Children.Sum(c => c.GetFieldValue<double>("Microsoft.VSTS.Scheduling.RemainingWork", 0d));
parent["Microsoft.VSTS.Scheduling.OriginalEstimate"] = parent.Children.Sum(c => c.GetFieldValue<double>("Microsoft.VSTS.Scheduling.OriginalEstimate", 0d));
//Step 3
parent["MyOrg.HasChildren"] = parent.Children.Any(c => !c.IsDeleted).ToString();

But this get the error :

Save failed: {
    "fieldReferenceName": null,
    "fieldStatusFlags": "none",
    "errorMessage": "TF401320: erreur de règle pour le champ Travail restant. Code d'erreur : ReadOnly, InvalidNotOldValue. 2 erreurs supplémentaires se sont produites durant la validation de l'élément de travail. Corrigez toutes les erreurs, puis réessayez.",
    "fieldStatusCode": 0,
    "ruleValidationErrors": [
        {
            "fieldReferenceName": "Microsoft.VSTS.Scheduling.RemainingWork",
            "fieldStatusFlags": "readOnly, invalidNotOldValue",
            "errorMessage": "TF401320: erreur de règle pour le champ Travail restant. Code d'erreur : ReadOnly, InvalidNotOldValue.",
            "fieldStatusCode": 16777218,
            "ruleValidationErrors": null
        },
        ...
        Same for Microsoft.VSTS.Scheduling.OriginalEstimate and Microsoft.VSTS.Scheduling.CompletedWork
}

I think Aggragator CLI send all values in one query. It's possible to do intermediate save in rule?

@giuliov giuliov added enhancement New feature or request good first issue Good for newcomers labels Dec 4, 2020
@giuliov
Copy link
Member

giuliov commented Dec 4, 2020

Sorry for the delay.
Well the SaveChanges method is public and can be called, but it would be my second choice. In fact it isn't documented.

My first choice would be to set the bypassRules flag except that you cannot set it independently but it is tied to the impersonate directive.
It is not a complex change but I do not have time at the moment, so if you can submit a PR, I would be grateful... or be patient.

@giuliov
Copy link
Member

giuliov commented Mar 20, 2022

Tracking this in #255

@giuliov giuliov closed this as completed Mar 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant