Avoid loop with “UPDATE_TITLE_BLOCK” event trigger
Hi all,
I have a problem with a script that’s launched with the UPDATE_TITLE_BLOCK event trigger.
This script copies a text written in a text field in another text field and delete the content of the first field.
My goal is to have two field, one for the text input (always empty) and one (read only) where I’m appending the text written time by time in the first field.
The problem is that when I write in the first field and save the page it writes in the second field and sees it as an Update Title Block event generating a loop. Is there a way to avoid this behavior? Thanks!
In latest Agile versions (9.3.4 for sure), there is a new preference called “Event Maximum Nested Levels Allowed”. Set it to 1 to avoid title block events loop. default value is 10.
In earlier Agile versions, the code may check the existing value before writing, and avoid writing if value already exist. That will allow the event to occur only twice and will avoid longer loops.
Thanks for the answer Tal.
In my version (9.3.3) Event Maximum Nested Levels Allowed is set to 10 and it actually says “Error: Error: Error: Error: Error: Error: Error: Error: Error: Error: Max event level was reached. To prevent possible infinite loop, the action is stopped. “
It avoids long loops, but the result is that it doesn’t do what I would like it to do (it actually does nothing).
I tried to put a verify step in my code but seems like nothing has changed.
My code is the following, I put the if(!D1NotesWrite.equalsIgnoreCase(“”)), so it should copy the field, start again and do nothing after finding the D1NotesWriteCell empty; it returns the same error, what am I doing wrong?
String D1NotesFinal = “”;
String D1NotesWrite = currentChange.getValue(ChangeConstants.ATT_PAGE_THREE_MULTITEXT10).toString();
String D1Notes = currentChange.getValue(ChangeConstants.ATT_PAGE_THREE_MULTITEXT20).toString();
if(!D1NotesWrite.equalsIgnoreCase(“”)){
if(D1Notes.equalsIgnoreCase(“”)){
D1NotesFinal = D1NotesWrite;
} else {
D1NotesFinal = D1Notes + “nn” + D1NotesWrite;
}
ICell D1NotesWriteCell = currentChange.getCell(ChangeConstants.ATT_PAGE_THREE_MULTITEXT10);
ICell D1NotesCell = currentChange.getCell(ChangeConstants.ATT_PAGE_THREE_MULTITEXT20);
D1NotesWriteCell.setValue(“”);
D1NotesCell.setValue(D1NotesFinal);
}