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

Chuck Tomasi
Tera Patron

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


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!


lSurya 24
Giga Guru

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:


find_real_file.png


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