Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

Sys id displayed instead of Name in email notification

kun1
Tera Expert

Mail script:-

(function runMailScript(current, template, email, email_action, event) {

template.print(current.variables.property_authorization_card.Type+ '\n\n'+"<br/> Property card Details");

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

 

here issue is it provide me the sys id of Type. How to populate name instead of sys id.

1 ACCEPTED SOLUTION

search on google , you will find plenty of reference regarding the style .

try with below code. 

 

(function runMailScript(current, template, email, email_action, event) {

 

var arr =[];

var variableArray = JSON.parse(current.variables.property_authorization_card);

for(var i=0; i < variableArray.length; i++) {
 

var gr = new GlideRecord('table name');

gr.addQuery('sys_id','IN',variableArray[i].Type);

gr.query();

gs.log('Row count'+ gr.getRowCount());

while(gr.next()){


arr.push(gr.name);

}

}

template.print(arr+ '\n\n'+"<br/> Property card Details");

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

View solution in original post

26 REPLIES 26

If i selected multiple in the form, then how can we modify the code.

With the above code, ti displayed only one in the email notification

give a try to add multiple and see if that is working or not. 

I tried add multiple and it displayed only 1

find_real_file.png

try now. 

 

(function runMailScript(current, template, email, email_action, event) {

 

var variableArray = JSON.parse(current.variables.property_authorization_card);

for(var i=0; i < variableArray.length; i++) {
 

var gr = new GlideRecord('table name');

gr.addQuery('sys_id','IN',variableArray[i].Type);

gr.query();

gs.log('Row count'+ gr.getRowCount());

while(gr.next()){



template.print(gr.name+ '\n\n'+"<br/> Property card Details");

}

}

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

 

find_real_file.png

Its came like this. I need a new line and heading in bold