We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

make catalog task variables when state is closed

NiloferS
Tera Contributor

need to make catalog task variables read-only when the state field is closed. this should be applicable only for a particular catalog item. 

I have written onchnage clien script as below. its not working as anticipated.

Kindly suggest.

NiloferS_0-1718949882413.pngNiloferS_1-1718949918330.png

 

 

3 REPLIES 3

SN_Learn
Kilo Patron

Hi @NiloferS ,

 

Please have a look at the below:

How to set the variables READ ONLY once the SCTASK is closed 

Make Variables Field - Read Only in Catalog Task 

 

Mark this as Helpful / Accept the Solution if this helps

 

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.

Sandeep Rajput
Tera Patron

@NiloferS Please try the following script and see if it works for you.

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }

    //Type appropriate comment here, and begin script below
    var catalogitem = g_form.getDisplayBox('u_item').value;
    if (catalogitem == 'Request for Approval and Documents') {
        if (newValue == '3') {
            g_form.setVariablesReadOnly(true);
        }
    }
}

Rohit99
Mega Sage

Hi @NiloferS,

You can achieve mentioned requirement using UI policy.

Table : sc_task

Condition : Requested Item -> State is Closed Complete.

 

Attaching Screenshot for reference.

ui_policy_for_readonly.PNG

 

Please mark my response as correct and helpful if it helped solved your question.

 

Thanks,

Rohit Suryawanshi