
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2017 04:21 AM
Hi there,
we'd like to use the checklist templates on the incident form.
It would be quite good to force people to confirm (when trying to provide solution = state change) that there are still open checklist items ... .
Anything to be reused out there?
I think a client script on submit should be the most reasonable way ... other opinions?
Solved! Go to Solution.
- Labels:
-
Best Practices
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2017 04:48 AM
Script Include:
var Test = Class.create();
Test.prototype = {
initialize: function() {
},
isChecked: function(id){
var gr = new GlideRecord("checklist");
gr.addQuery("document", id);
gr.query();
while (gr.next()) {
var gr_checkListItem = new GlideRecord("checklist_item");
gr_checkListItem.addQuery("checklist", gr.sys_id);
gr_checkListItem.addQuery("complete", false);
gr_checkListItem.query();
if (gr_checkListItem.next())
return false;
else
return true;
}
},
type: 'Test'
};
BR:
(function executeRule(current, previous /*null when async*/) {
var res=new Test().isChecked(current.sys_id);
if(res)
gs.addInfoMessage("Checklist is reviewed.");
else
gs.addErrorMessage("Please review the checklist.");
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2017 04:28 AM
We have similar requirement and achieved using script include and called that in one of our BR (update).

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2017 04:30 AM
could u provide the script include code??? That would be helpful!
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2017 04:48 AM
Script Include:
var Test = Class.create();
Test.prototype = {
initialize: function() {
},
isChecked: function(id){
var gr = new GlideRecord("checklist");
gr.addQuery("document", id);
gr.query();
while (gr.next()) {
var gr_checkListItem = new GlideRecord("checklist_item");
gr_checkListItem.addQuery("checklist", gr.sys_id);
gr_checkListItem.addQuery("complete", false);
gr_checkListItem.query();
if (gr_checkListItem.next())
return false;
else
return true;
}
},
type: 'Test'
};
BR:
(function executeRule(current, previous /*null when async*/) {
var res=new Test().isChecked(current.sys_id);
if(res)
gs.addInfoMessage("Checklist is reviewed.");
else
gs.addErrorMessage("Please review the checklist.");
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-22-2017 05:21 AM
very cool - thank you.
Only thing I do not like at the moment is, that I cannot use confirm in a Business Rule as far I know ... so I cant let the user decide if to abort or not ...