Make checklist mandatory

João V Freitas
Tera Contributor

I am working on a personal project and I want to make checklists mandatory for a specific task. I checked some discussions in the community and came across a reply teaching a way to do it. (Solved: Checklist - Able to Make Mandatory and Able to App... - ServiceNow Community). But this method only let the record be updated in any way if all the boxes are checked off.
I want a way to make the all check boxes to be checked off as mandatory, I want to be able to check off the box that was completed and update the task, rather than having it say all check boxes need to be checked off before updating. So basically the end goal is to still be able to update the task and check off the items that are completed, but make it mandatory all boxes are checked off before closing the task.
Any advice on how to accomplish this?

1 ACCEPTED SOLUTION

Chaitanya ILCR
Kilo Patron

Hi @João V Freitas ,

create a Before update BR on your table

with condition like (state changes to closed) or (active Changes to False)

whatever is meaningful

ChaitanyaILCR_0-1752599565786.png

 

with script

ChaitanyaILCR_1-1752599642665.png

(function executeRule(current, previous /*null when async*/ ) {

    var gr = new GlideRecord("checklist_item");
    gr.addEncodedQuery('complete=false^checklist.document=' + current.getValue('sys_id'));
    gr.query();
    if (gr.hasNext()) {
        gs.addErrorMessage('close the active check lists');
        current.setAbortAction(true);
    }


})(current, previous);

I have taken problem table as an example but update it with you table name and add condition with above script

 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

 

 

View solution in original post

7 REPLIES 7

Chaitanya ILCR
Kilo Patron

Hi @João V Freitas ,

create a Before update BR on your table

with condition like (state changes to closed) or (active Changes to False)

whatever is meaningful

ChaitanyaILCR_0-1752599565786.png

 

with script

ChaitanyaILCR_1-1752599642665.png

(function executeRule(current, previous /*null when async*/ ) {

    var gr = new GlideRecord("checklist_item");
    gr.addEncodedQuery('complete=false^checklist.document=' + current.getValue('sys_id'));
    gr.query();
    if (gr.hasNext()) {
        gs.addErrorMessage('close the active check lists');
        current.setAbortAction(true);
    }


})(current, previous);

I have taken problem table as an example but update it with you table name and add condition with above script

 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

 

 

Hello @Chaitanya ILCR ,

That's it! This solved my issue. I already did a validation via client script to stop the submission when the state was changing to closed complete and not all checklist itens were checked off, but stuff like UI actions and even extensions that allow me to edit field values were overriding it.
Your method solved it perfectly, thanks a lot!

Juhi Poddar
Kilo Patron

Hello @João V Freitas 

If you are trying to achieve something like this

JuhiPoddar_0-1752600760831.png

Variables configuration setup:

JuhiPoddar_1-1752600873136.png

Hope this helps!

 

"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"

 

Thank You
Juhi Poddar

Hi Juhi,

I was refering to checklist formatters on task tables rather than the checkbox T/F variable.

But thanks for the reply!