
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-29-2016 02:09 PM
I have a basic scheduled job that kicks off a workflow.
I want to be able to pass the value of a variable to the workflow and use it within the workflow.
Here is the scheduled job that is intended to pass the value (currently it is just a hard-coded string for testing). Once this is working it will be an onchange client script via glideajax that will pass the value of the catalog item variable.
var gr = new GlideRecord('wf_workflow');
gr.addQuery('name', 'Hostname Check if Taken');
gr.query();
if (gr.next()) {
var wf = new Workflow();
var workflowId = '' + gr.sys_id;
var vars = {u_hostname: "hostname123"};
wf.startFlow(workflowId, current, current.operation, vars);
}
Then within the workflow there is a "Run Script" activity that sets the variable to the scratchpad and should print the value to the log. However the log shows that the variable is undefined. It should be as that hard-coded string "hostname123"
workflow.scratchpad.u_hostname = current.variables.u_hostname;
var hostname = workflow.scratchpad.u_hostname;
gs.log(hostname);
Solved! Go to Solution.
- Labels:
-
Integrations
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-29-2016 10:49 PM
I think you also need to configure this variable in workflow inputs and then the variable will be accessible using workflow.inputs.variable_name
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-29-2016 04:37 PM
Try modifying:
var vars = {u_hostname: "hostname123"};
To
var vars = {"u_hostname": "hostname123"};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-29-2016 10:42 PM
Hi,
Please replace the code:
var vars = {u_hostname: "hostname123"};
with
var vars = {};
vars.u_hostname = "hostname123";
Best Regards,
/Suraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-29-2016 10:49 PM
I think you also need to configure this variable in workflow inputs and then the variable will be accessible using workflow.inputs.variable_name
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-29-2016 10:52 PM