- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2022 03:53 PM
Hello,
There is a parent/child feature in Incident Management where a record can be added to an incident as that incident's parent record. If the parent record has been added, that same record cannot be added as a child. This is a OOTB recursive script.
I want to create this same feature to prevent recursive loop in my custom table. Can someone provide a script for me to use? I found the OOTB script, modified it but it doesn't work. No errors and I can add one ticket as both the parent and a child, which isn't correct.
Here is the OOTB script I modified.
var rt = new RecursionTester('u_additional_info', 'u_parent_info');
if (rt.isRecursive(current)) {
current.setAbortAction(true);
current.u_parent_info.setError(gs.getMessage('Invalid Parent Info'));
gs.addErrorMessage(gs.getMessage('The selected Parent Info loops back to this record (recursive sdq ticket loop)'));
}
Thanks in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2022 06:24 PM - edited 10-31-2022 06:25 PM
is 'u_additional_info' your custom table name?
var rt = new RecursionTester('tableName', 'parentReferenceFieldName');
if (rt.isRecursive(current)) {
current.setAbortAction(true);
current.parentReferenceFieldName.setError(gs.getMessage('Invalid Parent Incident'));
gs.addErrorMessage(gs.getMessage('The selected Parent Incident loops back to this record (recursive incident loop)'));
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2022 08:11 AM
Your script looks fine and I compared it to several other OOTB business rules.
Stupid question, but can you confirm these settings on your business rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2022 08:49 AM
Yes, it matches your screenshot.
when: before
Insert: true
Update: true
I'm not sure why it isn't working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2022 08:53 AM
I'm at a loss. I would suggest opening a case with support in the meantime.
If i think of anything else i will post here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2022 11:44 AM
Hi Mike,
Thank you for helping out. Is there any other script I might have overlooked and that is why it isn't working?