Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

How can we fetch task variable value in client script

AkashD462166574
Tera Contributor

Hello All,

My requirement is like when the status is changes to Pending then sub status should changed to customer action .

I have write client script on sc_task table and use type is on Change and field is status.

Below is script

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

Craig Gruwell
Mega Sage

Hi @AkashD462166574 

 

Try something like this:

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

    if (newValue == "-5") {
        g_form.setMandatory("u_substatus", true);
        g_form.setValue("u_substatus", "cust_action");
    }

}

Hello Craig,

Thank you for your reply. My requirement was about how to fetch variable values from a task. However, I have found a solution. Thank you for your time.