Need to pass catalog item variable to REST api inside Run Script in workflow

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-01-2020 05:51 AM
Hi guys,
i am trying to pass catalog item variable (u_user_id) in run script to call REST API. The variable should be used by REST API to execute next build job in jenkins. When ever we are running the workflow, jenkins is showing empty value in the REST API parameter. Please let me know if you need any further details.
Actually i have designed a catalog item with some variables. One of the variable is "User ID" (u_user_id)
in the workflow, i am storing that value in a workflow scratchpad variable. I dont want to use custom REST activity. So, i just created a Outbound REST message and given End point and given HTTP methods as GET and POST as well. and in the "Variable Substitutions" i have given Name as username, Escape Type is No Escaping and Test Value is ${u_user_id}.
Now in the work flow i have written a run script activity like this
I want to call Rest message from the workflow runscript. But the username parameter is not taking.
Please help me
Thanks in advance
Regards,
Indup

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-01-2020 07:06 AM
I think your issue is probably that u_user_id is not defined. If it's a scratchpad variable then you'll need to use g_scratchpad.u_user_id, or just access the variable directly with current.variables.u_user_id assuming this is running on the request item table. So that line would be:
r.setStringParameterNoEscape('username', current.variables.u_user_id);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-01-2020 08:11 AM
HI Brad Tilton,
Initially i tried with that itself and it was not working. IF you need clear picture plz let me know.
Regards,
Indup
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā10-01-2020 07:07 AM
Hi Please check the below link
https://developer.servicenow.com/dev.do#!/reference/api/orlando/rest/c_ServiceCatalogAPI
Mark my ANSWER as CORRECT and HELPFUL if it helps