The CreatorCon Call for Content is officially open! Get started here.

How to fetch current catalog task state inside catalog client script

Obito
Tera Expert

How to fetch current catalog task state inside catalog client script, so that I can compare if the state is close or not.

Please refer below image.

 

23121.png

2 ACCEPTED SOLUTIONS

Runjay Patel
Giga Sage

Hi @Obito ,

 

You can use code like below.

g_form.getValue('state')

It will give you current task state value.

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------

View solution in original post

@Obito 

if your requirement is to make all variables readonly when task is closed then use this script in normal onLoad client script on sc_task and not catalog client script

function onLoad() {
    if (g_form.getValue('state').toString() == '3')
        g_form.setVariablesReadOnly(true);
}

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

 

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

Hi @Ankur Bawiskar and @Obito ,

 

It should work, I have tried it in PDI and its working.

See the screenshot for reference.

 

RunjayPatel_0-1734939464727.png

 

RunjayPatel_1-1734939488698.png

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------

 

 

Obito
Tera Expert

@Ankur Bawiskar , @Runjay Patel  I tried both. Both are working, Thanks.