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 06:36 AM
Hi Martin,
Any idea where that PowerShell script came from? I'm no PS expert, but it would seem that the quotes are interpreting it as a literal string instead of the value of your variable. It makes me wonder if it shouldn't be something more like:
Where{ $_.name -eq \"current.variables.target_computer\" }
Just a hunch based on other languages and parsers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2017 06:51 AM
Hi Chuck,
thanks for your hint. The PowerShell script works fine when I manually enter a computer name in the workflow definition:
results in
in the script and it works fine. So it actually expects a string there.
The workflow activity contains input variables
that are then used in the execution command:
The error seems to be somewhere between the workflow definition where I need to specify the values for the activity input variables and the actual running activity. What I enter in the workflow definition is not "translated" to the values but taken 1:1.
Any ideas on that? I might do something very basic wrong, I am not that familiar with the ServiceNow workflows.
Thanks and kind regards,
Martin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-14-2017 07:03 AM
No idea on this one. steppek, any thoughts here?