Update an item causes recursive loop

オフライン

Hi team,

So I am looking to run a method on an item whenever it is updated to update two hidden properties on the item that drive some functionality later on down the workflow.

The issue I am having is that when I use the onAfterUpdate event, because the method updates the item it causes a recursive loop and runs itself indefinitely.

I attempted onAfterVersion however this caused two weird scenarios - the logging wouldn't show the correct result until the second time the item was saved and even then it never actually updated the properties. I have this same event running onAfterAdd and it works successfully there but I need it to update anytime the item is saved.

Finally, I got the idea to run it via a wrapper from a client event on the form. In this case, onFormPopulate causes the recursive loop again, and so I am attempting a field even for onChange of the field that drives these in question. It still seems to have an issue so any suggestions would be welcome.

Parents
  • Why not to use OnBeforeUpdate? In this case you don't need an additional update. Just change the properties of "this".

    this.setProperty("a_gpr_by_prodcat", setRegions);
    this.setProperty("a_design_center", setRegions);
    if (this.getProperty("a_eco_status") == null)
    {
        this.setProperty("a_eco_status", "Stage 1 of 11 - ECR Created");
    }
    return this;

Reply
  • Why not to use OnBeforeUpdate? In this case you don't need an additional update. Just change the properties of "this".

    this.setProperty("a_gpr_by_prodcat", setRegions);
    this.setProperty("a_design_center", setRegions);
    if (this.getProperty("a_eco_status") == null)
    {
        this.setProperty("a_eco_status", "Stage 1 of 11 - ECR Created");
    }
    return this;

Children