How to set variables on a requested item made from a script?

alexjyong
Giga Contributor

So I made a little REST script that will make a request into ServiceNow from a (mostly) publicly accessible web form.

Making the request is easy, and right after the request is generated, I immediately afterwards make a service catalog request that is tied to it. (all in the script) but when I view the service catalog request, it doesn't have variables that I can put the customer's data into.


Now, if I do this through the frontend (i.e. go to Self-Service >Requests, or Service Catalog > Requests), I'm prompted with adding the variables first for the catalog task, then a Request and a catalog task is made, along with the variables being shown in the catalog task.

When doing this from a REST Client, am I doing this out of order? Should I be making a sc_request first? But how do I populate the variables from the outside of SN? (through this script). I don't see where in the tables how the variables are connected to the service catalog items. (Or do I need to look at some other table?)

1 ACCEPTED SOLUTION

Brian Dailey1
Kilo Sage

Hi Alex,



Rather than copy paste a WHOLE lot of text in here, I'll point you to some posts I've made in other discussions with regards to the variable relationships.




So, first you will need to understand the relationship between tables... Then you can go about populating the needed values via your REST calls.   Depending on what platform you're using, you could probably combine the whole operation into one scripted REST call that populates all the info, instead of calling to each table.



Give the above a read, and then let us know what questions you have left to make it work.




Thanks,


-Brian


View solution in original post

5 REPLIES 5

Deepak Ingale1
Mega Sage

Hi Alex,



You can use the CART API for this.



CART API enables you to set variable information



http://wiki.servicenow.com/index.php?title=Service_Catalog_Script_API#gsc.tab=0