- 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-03-2021 11:08 PM
Hi,
Did you define the workflow inputs?
you should be using workflow.inputs.UserName to get the value
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-03-2021 11:16 PM
I actually didn't define any workflow inputs... should i have? would my input be UserName? type = string?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-03-2021 11:30 PM
As per docs you need to defined the input variables
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-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