Format Date/Time variable in notification subject line

purdue
Kilo Sage

Hello,

I would like to format end date variable to remove timezone.  Any assistance is appreciated.

Screenshot 2024-08-08 at 10.33.50 AM.pngScreenshot 2024-08-08 at 10.35.12 AM.png

1 ACCEPTED SOLUTION

Brian Lancaster
Tera Sage

I'm not sure you can. Normally I would say write a mail script like below but in testing I cannot seem to have a mail script in the subject.

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

          // Add your code here
		  var date = current.variables.test.toString().split(' ');//convert data to a string and split it based on spaces
		  template.print(date[0] + " " + date[1]); //print only begging and middle
})(current, template, email, email_action, event);

View solution in original post

2 REPLIES 2

Brian Lancaster
Tera Sage

I'm not sure you can. Normally I would say write a mail script like below but in testing I cannot seem to have a mail script in the subject.

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

          // Add your code here
		  var date = current.variables.test.toString().split(' ');//convert data to a string and split it based on spaces
		  template.print(date[0] + " " + date[1]); //print only begging and middle
})(current, template, email, email_action, event);

Thanks Brian.   It works I was able to use to setsubject in mail script.

var grRITM= new GlideRecord("sc_req_item");


grRITM.addQuery("request", current.sys_id);


grRITM.query();


if(grRITM.next()){



var subj = '';


subj = (grRITM.request.item.name+' + " - " '+grRITM.variables.requested_for);


email.setSubject(subj);