what is current, template, email, email_action, event in this script?

BoHyun Jung
Mega Sage

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

var entries = current.comments.getJournalEntry(-1).split('\n\n');

//template.print('<div>'+entry+'</div><br>');
template.print('<ul style="list-style:none;" class = "mzc_comments_ul">');

for(var i = 0 ; i < 3 ; i++){


if(i<entries.length - 1){
template.print('<li class = "mzc_comments_li">');

var entry = entries[i];
var entry_obj = entry.split('\n');
var entry_info = entry_obj[0].split(' - ');
template.print('<div>');
template.print('<div class="info">'+entry_info[1]+'</div>');
template.print('<div class="info">'+entry_info[0].replace('KST','')+'</div>');
template.print('</div>');
template.print('<div class="comment">'+entry_obj[1].replace('[code]','').replace('[/code]','')+'</div>');

template.print('</li>');
}
}

template.print('</ul>');

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

 

 

what is current, template, email, email_action, event in this script?

Please explain one by one.(current, template, email, email_action, event)

 

1 ACCEPTED SOLUTION

Basheer
Mega Sage

Hi @BoHyun Jung 

current means the record on which your email is getting triggered, through this current object you can get the values of the columns of that record.

template means if you want to add any message through email script into the body then you need to use template.print("your message");

Email means if you want to add any optional email apart form the mail id which you've configured like setBody etc.,

Email Action means GlideRecordObject  for the email notification

Event means the GlideRecord object of the event.

 

More details you can find in this page:

https://docs.servicenow.com/bundle/rome-servicenow-platform/page/script/server-scripting/reference/r...

 

Please hit like button if my suggestion has helped you in any way.
Please mark correct if my response has solved your query.

Cheers,
Mohammed Basheer Ahmed.

View solution in original post

1 REPLY 1

Basheer
Mega Sage

Hi @BoHyun Jung 

current means the record on which your email is getting triggered, through this current object you can get the values of the columns of that record.

template means if you want to add any message through email script into the body then you need to use template.print("your message");

Email means if you want to add any optional email apart form the mail id which you've configured like setBody etc.,

Email Action means GlideRecordObject  for the email notification

Event means the GlideRecord object of the event.

 

More details you can find in this page:

https://docs.servicenow.com/bundle/rome-servicenow-platform/page/script/server-scripting/reference/r...

 

Please hit like button if my suggestion has helped you in any way.
Please mark correct if my response has solved your query.

Cheers,
Mohammed Basheer Ahmed.