Here's How to Write a Scripted REST API to Get Catalog Item Variables in ServiceNow via REST!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2016 01:18 PM
Howdy folks!
I recently wrote an article on how to create a scripted REST API to retrieve catalog item variables via REST (something you couldn't do previously, in Geneva and earlier), so I thought I'd share.
In helsinki, there's the sn_sc API that might make this possible, but this is still a quick and easy way to accomplish that, and for anyone still on Geneva or earlier, something like this is your only option for getting catalog item variables via web services.
SN Pro Tips — ServiceNow Scripted REST APIs & Retrieving Catalog Item Variables
Let me know your thoughts, and if you enjoy the article, I humbly welcome you to subscribe for more. 🙂
-Tim

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2016 10:09 AM
Hey Tim, this is cool. I know we did something similar at Expedia that was shared here;
And it's tasks returned the variables, not shown in screenshots
But this uses processor instead of the new scripted rest api's
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-04-2016 10:30 AM
Thanks Jace! Hope things are going swimmingly for all you folks over at Expedia. 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2017 10:23 AM
We used your processor and script include and it works great! Do you know what would need to be tweaked to return back the sysIDs of all the variables as well as additional values such help text and tool tips?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2017 12:39 PM
Not sure where you want those things.
If when quering for a item to request, you'd have to modify the method, `getCatalogItem
`
If you are asking that when you request a task and its variables you'd have to modify the method, `getTask
`
the getCatalogItem has teh properties you want so you should just be able to add them with code something like;
if (vars.default_value.toString() !== '') {
objToPush.column= vars.column.toString();
}
the getTask would be more difficult as you'd have to query the item definition for that item.