It's all about the answers!

Ask a question

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

Chandan M B (1133975) | asked May 06 '22, 8:20 a.m.


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);

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

        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";

One answer

permanent link
Ralph Schoon (63.2k33646) | answered May 06 '22, 8:26 a.m.

 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.

Chandan M B commented May 06 '22, 8:53 a.m.

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 

Ian Barnard commented May 10 '22, 5:32 a.m.

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 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.