Passing argument from workflow event activity to Script action

veeresh3
Tera Expert

Hi All,

Thanks for reading this.

I want to pass variable value from   workflow event activity to Script action for processing and getting the dynamic values for the my code.

for example: (Assumned that i have one variable in item)While Event activity occurs in the workflow,it call the script action script(Now i am using static data to process).Now i want to send the dynamic variable values to script action.

And how to set that passed varibale value in the below URL.

https://dhcp-manager.net.hban.us/wapi/v1.4.1/ipv4address?network=10.180.100.0/27&ip_address=10.180.1...

in the above URL the 10.180.100.0   is the static value. i want replace that value with my variable value.

I hope i made it clear here.

Please help me to resolve.

Thanks in Advence.

Thanks,

Veeresh

1 ACCEPTED SOLUTION

andrew_lawlor
Giga Expert

From your 'Create Event' activity, select your event name in the reference field. You can pass your catalog variable to your script action using either Parameter 1 or Parameter 2 - simply insert JavasScript into those fields to make it dynamic: ${workflow.variables.yourVariableName}



As for appending the parameter value to the URL you posted above - simply concatenate the strings: var myURL = 'https://dhcp-manager.net.hban.us/wapi/v1.4.1/ipv4address?network=10.180.100.0/27&ip_address=' + yourParameter;


View solution in original post

9 REPLIES 9

andrew_lawlor
Giga Expert

From your 'Create Event' activity, select your event name in the reference field. You can pass your catalog variable to your script action using either Parameter 1 or Parameter 2 - simply insert JavasScript into those fields to make it dynamic: ${workflow.variables.yourVariableName}



As for appending the parameter value to the URL you posted above - simply concatenate the strings: var myURL = 'https://dhcp-manager.net.hban.us/wapi/v1.4.1/ipv4address?network=10.180.100.0/27&ip_address=' + yourParameter;


Oh yeah - you can access parameters from your script action with the following syntax:


event.parm1


event.parm2


Can this be put into my notification? I want to refer to a REQ from a notification email, fired off of an event in a catalog item workflow


If you're firing your notification from an event, you should have access to both event.parm1 and event.parm2 from your Email Notification script - in addition to the 'current' object (in your case, a Requested Item).



Check out this old Wiki article for more details: Scripting for Email Notifications - ServiceNow Wiki