- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2021 10:29 PM
I am having trouble accessing the variable in my inbound action from my workflow
this is my inbound action that is used to kick the workflow off.
var userEmail = email.from;
var grUser = new GlideRecord(sys_user);
grUser.addQuery('email', userEmail.tostring());
grUser.query();
if (grUser.next()) {
var userName = grUser.user_name;
var fullName = grUser.name;
}
var wflow = new Workflow();
var wfId = wflow.getWorkflowFromName("BYODDeviceOptIn") ;
var vars= {};
vars.UserName = userName;
wflow.startFlow (wfId, current, current.operation() , vars) ;
--------------------------------------------------------------------------------------------------------------------------------
In my workflow, I have tried using workflow.inputs.UserName and workflow.variables.UserName but i when i log both of those i get undefined
How can i get the Value of UserName in my workflow?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2021 11:40 PM
Hi,
See the example here
1) Create workflow input variable
2) Then send the data like this
var inc = new GlideRecord('incident');
inc.get('8d44ecd62ff56010aedd55f62799b691');
inc.short_description = 'test';
inc.update();
var wflow = new Workflow();
var wfId = wflow.getWorkflowFromName("Incident") ;
var vars= {};
// you need to set the value in the same column name u_username
vars.u_username = 'my_id_to_workflow';
wflow.startFlow (wfId, inc, inc.operation() , vars) ;
3) Then access it like this
// u_username is the column name which you need to use to access the value
gs.info("workflow value"+ workflow.inputs.u_username);
Output:
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2021 10:25 AM
Thanks Ankur for your help with this.
I ended up going a completely different route and created a After update business rule on the table. instead of passing from the inbound action i passed directly from the record i was grabbing the user_name from.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-04-2021 09:33 PM
No worries.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2021 01:31 AM
How do we call startFlow() and pass current parameter in Client callable Script include?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2021 01:41 AM
Hi,
startFlow() is server side so you can include that in client callable script include
pass the parameters from client side to server side from GlideAjax
Please mark my above response as helpful
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2021 03:13 AM
I need to update some field using current in workflow Run Script activity.
Since we have to pass wfId,current,current.operation() and vars in startFlow(), and i guess we don't have access to "current" GR in client callable script include.
so can we pass current from client script to client callable script include using GlideAjax and if not, how startFlow() will be given parameters?