
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-20-2022 04:11 PM - edited ‎03-29-2024 09:26 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-20-2022 04:32 PM
Hi Bassam,
You have two possibilities:
1) update the ui action to resolve the incident, putting there the code to validate if all checklist items are compete or not. If not, abort the Resolution action;
2) on the onSubmit, validate if the state is being changed and only in that situation you will validate the checklist items:
function onSubmit() {
if (g_form.getValue("state") == 7) { //Closed
// Check to make sure checklist is complete before continuing
var ci = new GlideRecord('checklist_item');
ci.addQuery('checklist.document', g_form.getUniqueValue());
ci.addQuery('complete', false);
ci.query(); // Must be a synchronous call because this is an 'onSubmit' script
if (ci.next()) {
alert('All checklist items must be completed before this ticket is resolved.');
return false;
}
}
}
(update the value of state to the one you need).
In the end, you are only interested in checking the checklist when resolving/closing the record, so only on that moment you should validate the checklist.
Hope my answer helps you!
Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!
Best Regards,
Filipe Cruz

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-20-2022 04:32 PM
Hi Bassam,
You have two possibilities:
1) update the ui action to resolve the incident, putting there the code to validate if all checklist items are compete or not. If not, abort the Resolution action;
2) on the onSubmit, validate if the state is being changed and only in that situation you will validate the checklist items:
function onSubmit() {
if (g_form.getValue("state") == 7) { //Closed
// Check to make sure checklist is complete before continuing
var ci = new GlideRecord('checklist_item');
ci.addQuery('checklist.document', g_form.getUniqueValue());
ci.addQuery('complete', false);
ci.query(); // Must be a synchronous call because this is an 'onSubmit' script
if (ci.next()) {
alert('All checklist items must be completed before this ticket is resolved.');
return false;
}
}
}
(update the value of state to the one you need).
In the end, you are only interested in checking the checklist when resolving/closing the record, so only on that moment you should validate the checklist.
Hope my answer helps you!
Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!
Best Regards,
Filipe Cruz
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-29-2023 03:10 AM
Hey Guys i have found a workaround,
PFB the code and the configurations of the Business rule:
Configure a Business rule on HR task(sn_hr_core_task) table and run it before update and under filter condition set state as changes to close complete and HR task type is checklist.
Script: