- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-19-2017 09:46 AM
I think I have most of the components to have this work but i'm missing something.
I have workflow triggering an event to fire an notification. The event contains a parameter script to get a list of email addresses from a list of users from a list collector. I can generate the array no problem.
Create Event activity:
(function() {
var arrayEmail = [];
var gr = new GlideRecord('sc_req_item');
gr.addQuery('number', current.sys_id);
gr.query();
if (gr.next()) {
var arrayUtil = new ArrayUtil();
var list = gr.variables.proj_employee_remove_list.toString();
var arrayList = list.split('.');
l = arrayList.length;
for (var i=0; i<=l; i++) {
var ue = new GlideRecord('sys_user');
ue.addQuery('sys_id', 'IN', arrayList[i]);
ue.query();
while (ue.next()) {
arrayEmail += (ue.email + ',');
}}
return "arrayEmail";
}
}());
The problem is passing the email addresses to the notification. I have the parameter 1 selected in the notification. The event fires but returns the RITM that's associated with workflow. What else am i missing or doing incorrectly?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-19-2017 01:41 PM
Looks like I had an error with the first part of the query. It should have been a 'sys_id', current.sys_id
Second, the parameter needs to pass the sys_id of the users so the second half of the script was wholly unnecessary.
I'm not sure if the toString at the end is necessary since it's already in a string format but it didn't hurt.
Thanks for the suggestions!
(function() {
var arrayEmail = [];
var gr = new GlideRecord('sc_req_item');
gr.addQuery('sys_id', current.sys_id);
gr.query();
if (gr.next()) {
var arrayUtil = new ArrayUtil();
var list = gr.insertvariablename.toString();
var arrayList = list.split(',');
l = arrayList.length;
return arrayList.toString();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-15-2018 03:45 AM
Hi Kkim,
I have a similar requirement where I need to send the email notifications to a list of people configured in our custom form when the SLA configured exceeds 50%. This is achieved via workflow Run Script activity.
I have a field called Team Lead List which is a Glide List field in our custom form Location Based Assignments.
Now I need to send the emails to all the members in the team lead list field when sla exceeds 50%.
My script is as follows:
try
{
var arrayEmail = [];
var incLocation=current.task.location;
var incSupportGrp=current.task.assignment_group;
var usys_id=gs.getProperty('corporate.office.SDM.sysID');
var uname=gs.getProperty('corporate.office.SDM.name');
var gr=new GlideRecord('u_location_based_assignment');
gr.addQuery('u_location',incLocation);
gr.addQuery('u_support_group',incSupportGrp);
gr.query();
if(gr.next())
{
var arrayUtil = new ArrayUtil();
var leads = gr.u_team_lead_list.toString();
var arrayList =leads.split(",");
temp = arrayList.length;
//gs.print("Array Value: " + temp);
//gs.print("Array.length:" + temp.length);
for(i=0;i<temp;i++)
{
var usr = new GlideRecord('sys_user');
usr.addQuery('sys_id', 'IN', arrayList[i]);
usr.query();
while(usr.next()){
arrayEmail.push(usr.getValue[i]('email'));
}
}
gs.eventQueue('inc.50.SDM.event',current,arrayList.toString());
}
}
catch(e)
{
gs.log('in side catch:'+e,'w123');
}
But when I execute it I am not getting the sysid's of the user instead it setting some value like 'Created on <time>'
Please tell me how to fix this
Regards,
Priya