Help Needed with Email Script

SandeepKSingh
Kilo Sage

I have a custome table (u_wells_fargo_bank_india). I need a link in my notification triggered , If I click on the link, It wil redriect me to that Table with the count

2 ACCEPTED SOLUTIONS

Ravi Gaurav
Giga Sage

Its pretty Straight:-

 

(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
    /* Optional EmailOutbound */
    email, /* Optional GlideRecord */ email_action,
    /* Optional GlideRecord */
    event) {




    var query='u_account_type=current';
    var x = new GlideRecord('u_wells_fargo_bank_india');
    x.addEncodedQuery(query);
    x.query();
    if (x.next()) {
           var count=x.getRowCount(); //5

 var str="count of Record : "+"<a href=\"https://"+gs.getProperty('instanceName')+".service-now.com/u_wells_fargo_bank_india_list.do?sysparm_query="+query+"\">"+"The Count is "+count+"</a>";

 
 template.print(str);
    }


})(current, template, email, email_action, event);
 

View solution in original post

Ravi Gaurav
Giga Sage

can you also try with glide aggerate for only count :-


var ga = new GlideAggregate('u_wells_fargo_bank_india');
ga.addAggregate('COUNT');
ga.query();
var count = 0;
if (ga.next()) {
count = ga.getAggregate('COUNT');
}
gs.info('Record count for u_wells_fargo_bank_india: ' + count);
})(current, previous);

 

This just for count but earlier script will work as per all valid scenario

View solution in original post

2 REPLIES 2

Ravi Gaurav
Giga Sage

Its pretty Straight:-

 

(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
    /* Optional EmailOutbound */
    email, /* Optional GlideRecord */ email_action,
    /* Optional GlideRecord */
    event) {




    var query='u_account_type=current';
    var x = new GlideRecord('u_wells_fargo_bank_india');
    x.addEncodedQuery(query);
    x.query();
    if (x.next()) {
           var count=x.getRowCount(); //5

 var str="count of Record : "+"<a href=\"https://"+gs.getProperty('instanceName')+".service-now.com/u_wells_fargo_bank_india_list.do?sysparm_query="+query+"\">"+"The Count is "+count+"</a>";

 
 template.print(str);
    }


})(current, template, email, email_action, event);
 

Ravi Gaurav
Giga Sage

can you also try with glide aggerate for only count :-


var ga = new GlideAggregate('u_wells_fargo_bank_india');
ga.addAggregate('COUNT');
ga.query();
var count = 0;
if (ga.next()) {
count = ga.getAggregate('COUNT');
}
gs.info('Record count for u_wells_fargo_bank_india: ' + count);
})(current, previous);

 

This just for count but earlier script will work as per all valid scenario