- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello Everyone,
I have one requirement.
Requested for field is list collector type in Catalog item .if select multiple users then selected users related mail address are should populate in Task des under RITM.
For this i want script in Task event in Workflow.
How can i fix this problem
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
so email addresses of those users should be populated where?
Example: I am taking description field for my reference, you can use this advanced script in Create Catalog Task Activity
var myArray = current.variables.listCollectoVariableName.toString().split(','); // give your variable name here
var emailArray = [];
for (var i = 0; i < myArray.length; i++) {
//myArray[i];
var gr = new GlideRecord("sys_user");
gr.addQuery("sys_id", myArray[i]);
gr.query();
if (gr.next()) {
emailArray.push(gr.getValue('email'));
}
}
task.description = 'Email addresses are ' + emailArray.toString();
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I believe I took example of description field and you can enhance the logic further now.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello @Manohararuna
PLEASE Find the below logic
1. You need to create variable in that variable you need to store the emails of the requested for users.
2. You need to extract the requested for user's emails and push into an array list after that all the emails pushed then you need to set this emails on the description in the script action
3. try use the run script action in workflow if you want to use the workflow instead of flow.
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Thank You