Forum Discussion
christopher_gillis
8 years agoCommunity Manager
Hello,
I believe you're running into an infinite loop. When you create the new Document in your onAfterAdd event, you're also triggering another onAfterAdd for that new Document which in turn is creating another Document and triggering another onAfterAdd, etc.
There are two ways I can see around this.
Christopher Gillis Aras Labs Software Engineer
- Separate out these two Documents into separate ItemTypes: Design Document and Hello Documents (the actual names can change)
- Add a check for the classification of the document in your onAfterAdd event like the example below
Innovator myInnovator = this.getInnovator();
// Don't create a new Document for documents already created by this kind of event
if (this.getProperty("classification") == "Design Document") {
return this;
}
// Otherwise, create the new Document as normal
Item doc = myInnovator.newItem("Document","add");
doc.setProperty("item_number","Hello Document");
doc.setProperty("classification","Design Document");
doc = doc.apply();
return this;
Chris
Christopher Gillis Aras Labs Software Engineer