Passing variables to a workflow called from flow designer

Kai Tingey
Tera Guru

Hi All

I'm trying to use flow designer and i'm not sure how i'm supposed to pass variables from flow designer into a workflow

Specifically i'm trying to use a trigger condition on the sys_user table to the effect of 

where the user is making a change to their own record, and it's a specific change, call a workflow. The workflow will need some information about the user passed to it from flow designer so it can do it's thing. 

ideally i'd like to pass the current user records 'username' variable to the workflow, but even sys_id would be fine. just something so i can easily look up the user record in the workflow in order for it to do it's thing.

The servicenow documentation on the 'call a workflow' flow action is not particularly helpful.

-- edit --

ok after hitting save (duh) i get a new option with 'current' in the call a workflow activity. If i drag the current user data record in there, can i then use something like "current.sys_id" in the workflow to do a glide lookup on the user?

1 ACCEPTED SOLUTION

Kai Tingey
Tera Guru

found the solution to my own problem, it works exactly as described above in case anyone is wondering.

you just use current.(whatever) in your workflow and go from there.

View solution in original post

5 REPLIES 5

Kai Tingey
Tera Guru

found the solution to my own problem, it works exactly as described above in case anyone is wondering.

you just use current.(whatever) in your workflow and go from there.

Hey Kai,

I have tried passing a variable from flow designer to my Workflow. in flow designer i am setting the return variable to userID, 

Now when i go to workflow and try to use the userID like so current.userID it does not work, was there something else you did?

Hi Danny

is the userID something being put into a variable (e.g. a string), or are you using the current user calling the workflow?

in my usage i am doing it like this:

trigger: user makes a change to their own user record.  

in my workflow i use current.sys_id to get the sys ID of the current record that has kicked off the flow (which is the user's record)

I have a script that starts with this:

//called from flow designer

var gr = new GlideRecord('sys_user'); //get the record from the sys user table
gr.get(current.sys_id);

workflow.scratchpad.username = gr.user_name; //take the sam account name and put it in the scratchpad

then i can use that scratchpad variable for the username of the object.

however, if you want to take a variable from an input - and use that to look up a user - you'll need to use another mechanism. If you're using a string, you'll need to set up an input on your workflow and then pass the data from flow designer to that input when you call the flow. Then you can use "workflow.inputs.(yourinputname)" to use the data in your workflow.

Thanks,

i have it working now and passing into my custom powershell activity