Help with mail script

Thomas99
Tera Contributor

Hi,

 

I have a date field in the form (date_birth) which is in YYYY/MM/DD format. 

 

I want this to be changed to DD/MM/YYY format in an email notification. 

 

Can someone please help me with the mail script. One I created doesn't render the desired result. 

1 ACCEPTED SOLUTION

@Thomas99  Here is my testing result, i have tested on my personal instance.

Attached screenshot for your reference, it working perfectly at my end.

 

testing record.PNGtestign email script.PNGTesting data.PNG

View solution in original post

6 REPLIES 6

It worked! 

 

I had to change  gdt1.setDisplayValue(current.variables.date_of_birth); // Add your field Name

 

Thank you

 

 

Sandeep Rajput
Tera Patron
Tera Patron

@Thomas99 Here is an example mail script using which you can achieve the same result. Following script works on an HR Case. Please change it according to the DOB field on your current record.

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

    // Add your code here
    var dob = current.subject_person_hr_profile.date_of_birth.getDisplayValue();
	var dobArray = dob.split('/');
	var newDob = dobArray[2]+'/'+dobArray[1]+'/'+dobArray[0];
	template.print('old DOB '+ dob);
	template.print('new DOB '+newDob);
    


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