- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-17-2025 11:29 PM
I am using flow designer for automating my process now I have a situation I am using reference catalog variable and dot walking through it and asking for approval, but the problem is in table all the email of users are stored in string fields and how can I do scripting for approval in flow designer so that I need to extract email and query it in sys_user table and send approvals.
No scripting available for Approval activity
To the owners string field, I need to send approval
How can I achieve this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-18-2025 12:18 AM
Hello @kirankr2061,
Since Flow Designer's "Ask for Approval" action requires user references, but you're working with email addresses stored as strings, you'll need to convert those emails into user records dynamically. To do this, create a Custom Action that takes the owner string field as an input, processes the email addresses, queries the sys_user table, and pushes the valid user records into an array. Set this array as the output of your custom action. Then, place this custom action right before the "Ask for Approval" step in your flow, and use the output array from the custom action as the input for the approvers in the approval step.
Use below script in the custom action:
(function execute(inputs, outputs) {
var emails = inputs.emailString.split(','); // assume comma-separated
var approvers = [];
emails.forEach(function(email) {
email = email.trim();
var userGR = new GlideRecord('sys_user');
userGR.addQuery('email', email);
userGR.query();
if (userGR.next()) {
approvers.push(userGR.getUniqueValue()); // push sys_id
}
});
outputs.approverList = approvers; // return array of sys_ids
})(inputs, outputs);
Please mark my solution as helpful and accepted for future reference.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-18-2025 12:34 AM
To handle this scenario in ServiceNow Flow Designer, where you're using a reference catalog variable and need to dot-walk to extract an email stored as a string, then query the sys_user table to send approvals, you can follow this approach:
Use a Script Step to Query sys_user
You’ll need a Script step in Flow Designer to query the sys_user table using the email string.
Here’s a sample script you can use in the Script step:
(function execute(inputs, outputs) {
var email = inputs.email_string; // This should be the dot-walked email string
var userGR = new GlideRecord('sys_user');
userGR.addQuery('email', email);
userGR.query();
if (userGR.next()) {
outputs.approver_sys_id = userGR.getValue('sys_id');
} else {
outputs.approver_sys_id = ''; // Handle case where user is not found
}
})(inputs, outputs);
Inputs and Outputs
- Input: email_string — the email string from your catalog variable (dot-walked).
- Output: approver_sys_id — the sys_id of the user to be used in the approval action.
Use the Output in the Approval Action
In the Approval step, use the approver_sys_id from the script output as the Approver.
Example Flow Steps
- Trigger: Catalog item submitted.
- Script Step: Extract email and query sys_user.
- Approval Step: Use approver_sys_id from script output.
Stay awesome,
Roshnee Dash
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-18-2025 12:34 AM
To handle this scenario in ServiceNow Flow Designer, where you're using a reference catalog variable and need to dot-walk to extract an email stored as a string, then query the sys_user table to send approvals, you can follow this approach:
Use a Script Step to Query sys_user
You’ll need a Script step in Flow Designer to query the sys_user table using the email string.
Here’s a sample script you can use in the Script step:
(function execute(inputs, outputs) {
var email = inputs.email_string; // This should be the dot-walked email string
var userGR = new GlideRecord('sys_user');
userGR.addQuery('email', email);
userGR.query();
if (userGR.next()) {
outputs.approver_sys_id = userGR.getValue('sys_id');
} else {
outputs.approver_sys_id = ''; // Handle case where user is not found
}
})(inputs, outputs);
Inputs and Outputs
- Input: email_string — the email string from your catalog variable (dot-walked).
- Output: approver_sys_id — the sys_id of the user to be used in the approval action.
Use the Output in the Approval Action
In the Approval step, use the approver_sys_id from the script output as the Approver.
Example Flow Steps
- Trigger: Catalog item submitted.
- Script Step: Extract email and query sys_user.
- Approval Step: Use approver_sys_id from script output.
Stay awesome,
Roshnee Dash
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-18-2025 12:46 AM
The script you mentioned is it an action? what is the name of that action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-18-2025 01:09 AM
Hi @kirankr2061
You need to create a custom action for this.
Stay awesome,
Roshnee Dash