- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2018 11:15 PM
I have a requirement to send 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
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2019 01:31 AM
Okay, great.
Could you mark my answer as correct/helpful if this helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2019 10:29 PM
Hi gspriya,
I think that is because you are passing current record in the evenqueue. In that place, pass the current user object instead of current and it should work.
Mark the answer as helpful if this works.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2019 01:13 AM
Hi Asifnoor,
What should I be passing instead of current.
I tried giving usr.user_name there but not working for that also.
Regards,
Priya

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2019 01:25 AM
Hi Priya,
Kindly pass the usr (Object) instead of current and it should work.
Mark correct/helpful if this works.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2019 02:08 AM
Hi Asif,
I tried giving usr object. but the event got generated only for the first user in the list.
Regards,
Priya

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2019 02:21 AM
Hi Priya,
So you are saying only 1 event got generated or 3 events with the same data?
If only 1 event, try adding log in your loop and check how many times it is running in the loop. We have only changed the variable from current to usr, nothing else. So your loop should still run.
Also, hope you have corected the spelling of uname in the above script.