Access variables in a workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2017 05:00 AM
Hello,
I created a new Catalog Item Request workflow including a custom workflow activity that runs a PowerShell script. For this activity I created two input variables that are used in the script. I am now struggeling with how to access those variables from the workflow. The variables are:
- a custom attribute on the catalog item ("Software ID" in Screenshot below)
- a (global) catalog variable with reference to the cmdb_ci_computer table ("Computer" in screenshot below)
Can anyone help me what I need to enter there? In other threads I found "current.variables.<variablename>" which did not work out.
Thanks in advance for your help,
Martin
- Labels:
-
Service Catalog
-
Workflow

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2017 05:02 AM
Hi Martin,
Variables from a catalog item are referenced via script in this way:
var myVar = current.variables.variable_name;
http://wiki.servicenow.com/index.php?title=Scriptable_Service_Catalog_Variables#gsc.tab=0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-18-2017 01:23 AM
Hi,
quick update on this: For the catalog variable it worked using "${current.variables.target_computer.name}" so it was basically a syntax topic .
However, I am not getting the catalog item attribute into the Script. The attribute is on the catalog item and the workflow is running on the requested item. My tries so far were:
- ${current.<attribute_name>}
- ${current.item.<attribute_name>}
- ${current.variables.<attribute_name>}
- ${current.sc_cat_item.<attribute_name>}
The result in the script is in all cases empty. Is it possible to dot-walk from there to the attribute or do I need to do anything else to get it?
Thanks in advance for your support!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2017 05:03 AM
Hello martin,
This might help:
Pass Catalog Item Variable to Workflow input
Accessing Catalog Item data from within a workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2017 06:33 AM
Hi Surya,
thank you for your answer. I have seen these threads but unfortunately they don't help.
From what I read there I should be able to access the variables with current.variables.variable_name, in my case current.variables.target_computer. However, when I do so and look at the ECC Queue of the workflow, it shows me that the following is entered into the PS script:
So it does not "transform" it to the actual value of the variable but puts exactly into the script what I entered in the workflow definition.
Any ideas?
Thanks and kind regards,
Martin