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

Indup
Tera Expert

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

find_real_file.png

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

3 REPLIES 3

Brad Tilton
ServiceNow Employee
ServiceNow Employee

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);

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

Ct111
Giga Sage

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