Restrict the Task state field from the list view

mastanbabuk
Tera Contributor

I need to restrict the state field. If mandatory fields are not fillled or empty in task record.  we not allow to close complete from Iist View. And need to show the alert or error message in current RITM. 

2 REPLIES 2

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @mastanbabuk 

 

You need to write the OncellEdit Client script for this.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Yes I have written the On Cell edit Scripts.  But it seems its not working 

 

 var manDat = ['publisher_part_number', 'po_number', 'vendor'];
    var taskGr = new GlideRecord('sc_task');
    if (taskGr.get(sysIDs[0])) {
        for (var i = 0; i < manDat.length; i++) {
            var Fields = manDat[i];
            if (taskGr.isValidField(Fields) && taskGr[Fields].nil()) {
                if (newValue == 'close complete') {
               g_form.addErrorMessage('You cannot close or complete this task until all mandatory fields are filled.');
                    callback(false);
                    return;
                }
            }

        }

    }
    callback(true);