- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2019 03:26 AM
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.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2019 05:08 AM
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);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2019 04:03 AM
Hi Kun
Have you tried just using name after type. BTW your question is very vague please provide more detail next time for example what field is type? Is it a reference field? What does the field reference etc? It helps knowing these kinds of detail.
I suggest you do the following in your mail script. My answer is assuming the field is a reference field to some table and that this table does have the name field.
(function runMailScript(current, template, email, email_action, event) {
template.print(current.variables.property_authorization_card.type.name+ '\n\n'+"<br/> Property card Details");
})(current, template, email, email_action, event);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2019 04:33 AM
I tried with this but still it give me undefined.
Field is reference type and its came under the variable set which is of multi line variable type

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2019 04:35 AM
try now
(function runMailScript(current, template, email, email_action, event) {
template.print(current.variables.Type.getDisplayValue()+ '\n\n'+"<br/> Property card Details");
})(current, template, email, email_action, event);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2019 04:36 AM
Nope!! Still undefined

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2019 04:42 AM
Are you trying to run a mail script in a catalog item?