Some PDIs are currently unavailable, and PDI actions are paused. View the latest updates here. Read More

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

Hi @mastanbabuk 

 

You need to write the OncellEdit Client script for this.

*************************************************************************************************************
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

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

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);