Access variables in a workflow

martin_kohler
Kilo Contributor

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)

find_real_file.png

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

7 REPLIES 7

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.


Hi Chuck,



thanks for your hint. The PowerShell script works fine when I manually enter a computer name in the workflow definition:


find_real_file.png


results in


find_real_file.png


in the script and it works fine. So it actually expects a string there.



The workflow activity contains input variables


find_real_file.png


that are then used in the execution command:


find_real_file.png



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


No idea on this one. steppek, any thoughts here?