- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2025 08:28 AM - edited ‎06-02-2025 08:34 AM
I already have a functional biz rule running to prevent resolution when our incidents have open incident tasks:
(function executeRule(current, previous /*null when async*/) {
incitask=new GlideRecord('incident_task');
incitask.addQuery('parent',current.sys_id);
incitask.addQuery('state','!=','3'); //Closed complete
incitask.addQuery('state','!=','4'); //Closed incomplete
incitask.addQuery('state','!=','7'); //Closed skipped
incitask.query();
if(incitask.next())
{
gs.addErrorMessage('Incident cannot be closed as Incident child task is still open');
current.setAbortAction(true);
}
})(current, previous);
And I was given a new requirement, to also prevent resolution of incidents with open items in their checklist. So I mocked up this:
(function executeRule(current, previous /*null when async*/) {
ci = new GlideRecord('checklist_item');
ci.addQuery('checklist.document', g_form.getUniqueValue());
ci.addQuery('complete', false);
ci.query();
if (ci.next()) {
gs.addErrorMessage('Incident cannot be closed as one or more checklist item(s) remain open');
current.setAbortAction(true);
}
})(current, previous);
This attempt isn't working, neither scripted into the same rule checking for incident tasks nor running as it's own biz rule (order 2). Does anyone see what's wrong with it?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2025 08:34 AM
You are using g_form.getUniqueValue() in a business rule which is causing the issue.
g_form.getUniqueValue()
You should be using current.getUniqueValue()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2025 08:34 AM
You are using g_form.getUniqueValue() in a business rule which is causing the issue.
g_form.getUniqueValue()
You should be using current.getUniqueValue()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2025 08:36 AM
Perfect, it's fixed. Thank you!