get value of a variable set inside a workflow

mikbri
Giga Contributor

Hi @all,

 

is there an easy and fast way to get the content of a Variable Set Value from a Service Catalog Item inside a workflow?

 

Example:

The user adds PC stuff to his cart and a mandatory field need the information who has to approve his request. The user have to specifie an approver. And then I want to create an incident which is directly assigned to this entered user/approver...

 

How I can do this?

 

Thanks

Mike

1 ACCEPTED SOLUTION

jim pisello
Giga Expert

Hi Mike,



In any workflow, you can get the value of a variable by using the notation current.variables.<variablename>. In the case of a reference variable, you'll get the sys_id of the referenced record.



To take your specific example, you can add a Create Task activity to your workflow and use the Script field in that activity to assign the task to the user referenced in the variable like this:


task.assigned_to = current.variables.<variablename>;



Where <variablename> is the name you've assigned to the reference variable.



With all of that said, I'm not sure I understand why you'd want to create an incident for a user who needs to approve a service request item. Wouldn't it make more sense to just use an Approval - User activity and assign the person in the reference variable as the approver? Using an incident to record an approval doesn't make any sense to me. The system isn't set up to support this, the approver would need a process user role (like itil) in order to resolve the incident, and you'd need to link the Incident to the Requested Item record via the Parent field. All of that sounds like a lot of work to imperfectly recreate what ServiceNow already does much better with Approval records.


View solution in original post

6 REPLIES 6

Hey Ashish, as James mentioned you wouldn't typically create and assign an incident for approval. This will be managed nicely by the Approval - User activity.


EdenOrZedaka
Tera Contributor

Does anyone have an answer to this question?
Is it possible to define variable sets within a run script cube in a workflow?