Display a variable in Tasks

KouassiP
Tera Contributor

Hello All , 

 

I have an item with 2 tasks and i want to make editable the vatiable in the Task 1 and in read only in the task 2 ... How is the best way to do this ?

Thank you for your support

2 ACCEPTED SOLUTIONS

Ankur Bawiskar
Tera Patron
Tera Patron

@KouassiP 

you can use onLoad normal client script on sc_task and not catalog client script

Check the task description and see if it's 1st or 2nd and then make the variable editable

function onLoad() {

    var shortDesc = g_form.getValue('short_description');
    if (shortDesc == 'task 1 short description') {
        g_form.setReadonly('variables.variableName', false);
    } else {
        g_form.setReadonly('variables.variableName', true);
    }

}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

@KouassiP 

yes catalog task sc_task since you mentioned catalog item

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

@KouassiP 

you can use onLoad normal client script on sc_task and not catalog client script

Check the task description and see if it's 1st or 2nd and then make the variable editable

function onLoad() {

    var shortDesc = g_form.getValue('short_description');
    if (shortDesc == 'task 1 short description') {
        g_form.setReadonly('variables.variableName', false);
    } else {
        g_form.setReadonly('variables.variableName', true);
    }

}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

When you talk about sc_task , you mean a DYnamic activity ?

@KouassiP 

yes catalog task sc_task since you mentioned catalog item

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@KouassiP 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader