Mail script - where are my line breaks?

kchorny
Tera Guru

I'm trying to print catalog variables in an email, but the line breaks aren't working and everything prints on one line.  Why?

Here's the email template configuration:

find_real_file.png

And the mail script:

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

var travelFor = '';
if (current.variables.tr_requesting_travel_for == 'tr_myself')
travelFor = current.request.requested_for;
else if (current.variables.tr_requesting_travel_for == 'tr_another_involta_employee')
travelFor = current.variables.tr_employee;
var u = new GlideRecord('sys_user');
u.get(travelFor);
var name = u.name;
var hotel = 'No';
var flight = 'No';
var rentalCar = 'No';
if (current.variables.tr_hotel == 'true')
hotel = 'Yes';
if (current.variables.tr_flight == 'true')
flight = 'Yes';
if (current.variables.tr_rental_car == 'true')
rentalCar = 'Yes';
if (current.variables.tr_trip_type == 'tr_multi_stop')
{
template.print(name);
template.print('\n' + 'Flight: ' + flight + ' Hotel: ' + hotel + ' Rental car: ' + rentalCar);
template.print('\n' + 'Departing on: '+ current.variables.tr_departure_date);
template.print('\n' + 'Traveling to: ' + current.variables.tr_traveling_to);
template.print('\n' + 'and ' + current.variables.tr_is_traveling_to);
template.print('\n' + 'Returning on: ' + current.variables.tr_return_date);
template.print('\n' + 'Reason for travel: ' + current.variables.tr_reason_for_travel);
}
else
template.print(name);
template.print('\n' + 'Flight: ' + flight + ' Hotel: ' + hotel + ' Rental car: ' + rentalCar);
template.print('\n' + 'Departing on: '+ current.variables.tr_departure_date);
template.print('\n' + 'Traveling to: ' + current.variables.tr_traveling_to);
template.print('\n' + 'Returning on: ' + current.variables.tr_return_date);
template.print('\n' + 'Reason for travel: ' + current.variables.tr_reason_for_travel);
})(current, template, email, email_action, event);

I've tried everything short of creating separate mail scripts for each variable but I still see this:

find_real_file.png

 

1 ACCEPTED SOLUTION

michellemmurtha
Giga Contributor

Since you are sending as HTML, instead of using \n, have you tried using <br> instead?

View solution in original post

3 REPLIES 3

michellemmurtha
Giga Contributor

Since you are sending as HTML, instead of using \n, have you tried using <br> instead?

Ugh! Why didn't I think of that!  🙂  Thank you so much, I was pulling my hair out.

Javier Arroyo
Kilo Guru

Does toggling the Newlines to HTML field in the Notification Email Script have any effect?