API to get SCTASK variables

Hari1
Mega Sage

Hi,

I have a requirement to get SCTASK catalog variables. Can this be achieved?

 

1 ACCEPTED SOLUTION

Hi Ankur,

Was able to achieve this by using the below API.

https:<instance url>/api/now/table/sc_task?sysparm_query=number=<sc_task number>&sysparm_display_val...

We can directly add the variables.<variablename> in the link.

View solution in original post

7 REPLIES 7

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

variables information is stored at RITM level

you will have to do 2 API calls

1) get RITM for your SC Task

2) Then query with variables.xxxx=YYYYYY for those RITMs

OR

You need to create Scripted REST API and then get the record matching the query

refer below link

Scripted REST APIs & Retrieving RITM Variables via SRAPI

Regards
Ankur

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

Hi Ankur,

Was able to achieve this by using the below API.

https:<instance url>/api/now/table/sc_task?sysparm_query=number=<sc_task number>&sysparm_display_val...

We can directly add the variables.<variablename> in the link.

I did the same and I can see the variables in the API results.  However, I have been trying to set fields on the receiving end of the API to be equal to the variables but I am not having luck.  I am able to set the fields from sc_task to the fields on my form but not the variables.  I have tried gr.field1 = variables.<variable_name>; but it is not working.  I am trying to explore other ideas but curious if you could shed some light on what you did after setting up the API and endpoint.  Thank you

Hi,

So you are trying to update variable value via API or using some script?

Can you share some details on this

Also since this is an old thread I would suggest to create a new question and you can tag me there.

Regards
Ankur

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