Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

ARTIFACT_SAVED Event in DNG is going for endless loop for updating an attribute value in Doors Next Extension

 Hello,


I am using an Event ARTIFACT_SAVED, where I am trying to update the attribute value of a requirement. Even though code works, it is calling infinite number of times and filling the values continuously for an attribute.
My code block looks like below

    var toSave = [];
        let attrResult = await services.getAttributes(selection);
        console.log(attrResult[0].values["XXX"]);

        await attrResult.forEach(item => {
            var current = item.values["XXX"];
            var newTextValues = constructFindings(current);
            if (newTextValues) {
                // Reuse the existing RM.ArtifactAttributes
                item.values['XXX'] = newTextValues;
                toSave.push(item);
            }
        });
       

        let operationResult = await services.setAttributes(toSave);
        for (p of operationResult) {
            if (p.code != "OK") {
                console.log(p.code + " Problem update artifact '" + p.message);
                return "ERROR";
            }
        }

0 votes



One answer

Permanent link

 I would consider this a "recursion" where a save is caught and an update (a save) is performed, which causes another trigger, which causes another update and so forth. This would be expected behavior, unless you build a mechanism that detects the update has been done and breaks the recursion.

0 votes

Comments

Yes it is recursion But I am not understanding why the save event is calling more than once in Doors Next when we modify only one time. Event is captured recursively 

If you're saving a value to the attribute that's going to cause another Event ARTIFACT_SAVED. Have you tried changing your code so it doesn't save to the attribute  unless the value has changed from what it already is? And ensure that the new value isn't dependent on its previous value else you'll still get recursive changes.

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,939

Question asked: May 06 '22, 8:20 a.m.

Question was seen: 877 times

Last updated: May 10 '22, 5:32 a.m.

Confirmation Cancel Confirm