Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
A business rule that verifies all checklist items are completed before allowing the record to progress to the next status.

The business rule consists of three main parts:

Part A: Looks up all checklists (checklist table) tied to the current record (document = current.sys_id).

Part B: For each checklist, query the checklist_item records:

Only items in that checklist.

Only items that are not complete (complete = false).

Part C: If any incomplete items exist, an error message is displayed and the action is aborted.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//Business Rule: before update on the incident table
//Condition: changing state to 'In Progress'
(function executeRule(current, previous /*null when async*/) {
var checklistGR = new GlideRecord("checklist");
checklistGR.addQuery("document", current.sys_id);
checklistGR.query();

while (checklistGR.next()) {
var itemGR = new GlideRecord("checklist_item");
itemGR.addQuery("checklist", checklistGR.sys_id);
itemGR.addQuery("complete", false);
itemGR.query();

if (itemGR.hasNext()) {
gs.addErrorMessage('Checklist has incomplete items. Please complete all before assigning it back.');
current.setAbortAction(true);
break; // stop after first failure
}
}
})(current, previous);
Loading