Template print a list of records in email notification

Richard Thomas2
Tera Contributor

Hi everybody,

I have the following email notification script and it want to display the list of cases

var cases = new GlideAggregate('x_rbos2_facilities_job');
cases.addQuery('location.country', gs.getProperty('x_rbos2_facilities.uk.country_id'));//Only UK locations
cases.addEncodedQuery('sys_created_onRELATIVEGT@dayofweek@ago@14');//Last 14 days
cases.addAggregate('COUNT');
cases.groupBy('location');
cases.query();
while (cases.next()) {
    
template.print(cases.number.getDisplayValue() +": " + cases.location.getDisplayValue() +": " + cases.location.contact.getDisplayValue());
       
}

However when I test the notification - I get the following. it's only printing the locations

 

find_real_file.png

Can anyone advise?

Thanks

Richard

1 ACCEPTED SOLUTION

Mohith Devatte
Tera Sage
Tera Sage

Hello @Richard Thomas ,

in the glide aggregate you cant get the access of variables except the grouped by field 

try this

var cases = new GlideAggregate('x_rbos2_facilities_job');
cases.addQuery('location.country', gs.getProperty('x_rbos2_facilities.uk.country_id'));//Only UK locations
cases.addEncodedQuery('sys_created_onRELATIVEGT@dayofweek@ago@14');//Last 14 days
cases.addAggregate('COUNT');
cases.groupBy('location');
cases.query();
while (cases.next()) {
    var num = new GlideRecord('x_rbos2_facilities_job');
  num.addQuery('location',cases.location);
num.query();
if(num.next())
{
template.print(num.number.getDisplayValue() +": " +num.location.getDisplayValue() +": " +num.location.contact.getDisplayValue());
}
       
}

MARK MY ANSWER CORRECT IT IT HELPS YOU

View solution in original post

2 REPLIES 2

Mohith Devatte
Tera Sage
Tera Sage

Hello @Richard Thomas ,

in the glide aggregate you cant get the access of variables except the grouped by field 

try this

var cases = new GlideAggregate('x_rbos2_facilities_job');
cases.addQuery('location.country', gs.getProperty('x_rbos2_facilities.uk.country_id'));//Only UK locations
cases.addEncodedQuery('sys_created_onRELATIVEGT@dayofweek@ago@14');//Last 14 days
cases.addAggregate('COUNT');
cases.groupBy('location');
cases.query();
while (cases.next()) {
    var num = new GlideRecord('x_rbos2_facilities_job');
  num.addQuery('location',cases.location);
num.query();
if(num.next())
{
template.print(num.number.getDisplayValue() +": " +num.location.getDisplayValue() +": " +num.location.contact.getDisplayValue());
}
       
}

MARK MY ANSWER CORRECT IT IT HELPS YOU

Richard Thomas2
Tera Contributor

Thank you Mohith!