- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2025 02:29 PM
Hi, I have a multi-line text variable that is called on in a notification. When the email notification goes out, all the entries in the variable run on continuous line even if they are spaced in the variable.
This is what the email recipient currently receives:
Hello Brad,
A request was submitted for you to be able to access the queue:
dfjdj dcghjehj dfhsg
This can also be found in the network folder located at [copy/paste this network folder path into the file explorer window address bar]: fgkhfjk fhkfuk fgkdhg
This is what i would like the email recipient to receive:
Hello Brad,
A request was submitted for you to be able to access the queue:
dfjdj
dcghjehj
dfhsg
This can also be found in the network folder located at [copy/paste this network folder path into the file explorer window address bar]:
fgkhfjk
fhkfuk
fgkdhg
Thank you for looking any help would be appreciated.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2025 03:55 PM
Hi @Bradley Bush ,
Can you give this option a try and let me know how it goes.
1. Create a mail script to handle the multiline text
2. Check the below option
3. Use in the notification.
Please mark helpful or correct if it worked out fine.
Johnny
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2025 03:53 PM
Hi Johnny, yes the other variables are multi-line.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2025 04:09 PM
@Bradley Bush yes in that case you would want them to be added in a mail script. However, I'm not sure of the exact requirement, I think you can add all the multi line text in one mail script and show them as per condition if required. I'll let you figure that out as per your requirement, if you not able to figure out let us know.
Also can you please mark the above answer correct since it helped you resolve the issue. This will benefit future readers.
Johnny
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2025 06:15 PM
Hi @Bradley Bush,
As per need, the multiline text value need to read and split based on newLine character ( "\n") and print in loop.
You can write this code in email script and add the email script to notification using ${main_script:<email_script_name>}
Use the below code to convert multiline value in separate lines.
// Assume 'multilineText' is the variable containing the multiline text
var multilineText = current.variables.multiline_field; // Replace 'multiline_field' with your actual field name
// Split the multiline text into an array using the newline character
var lines = multilineText.split('\n');
// Loop through the lines and print each one
for (var i = 0; i < lines.length; i++) {
template.print(lines[i] + '<br>'); // Use '<br>' for line breaks in HTML emails
}
-Thanks,
AshishKM
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2025 12:26 PM
hi AshishKM,
thank you for helping with the code. below is your code with the variable replaced, where i put the mail script, and the output. not sure if i'm missing something else, the output is still the same.
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
// Add your code here
// Assume 'multilineText' is the variable containing the multiline text
var multilineText = current.variables.right_task_queue; // Replace 'multiline_field' with your actual field name
// Split the multiline text into an array using the newline character
var lines = multilineText.split('\n');
// Loop through the lines and print each one
for (var i = 0; i < lines.length; i++) {
template.print(lines[i] + '<br>'); // Use '<br>' for line breaks in HTML emails
}
})(current, template, email, email_action, event);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2025 12:15 PM
hi, i have tried checking the "Newlines to HTML" and using the code provided, still same output. I revamped the script and still get the same output. Any other thoughts or suggestions?
(function runMailScript(/* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */ email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */ event) {
// Assume 'multilineText' is the variable containing the multiline text
var multilineText = current.variables.right_task_queue; // Replace 'right_task_queue' with your actual field name
// Check if multilineText is defined and not null to avoid errors
if (multilineText) {
// Replace any \r\n combinations with \n to handle Windows-style line endings
multilineText = multilineText.replace(/\r\n/g, '\n');
// Split the multiline text into an array using the newline character
var lines = multilineText.split('\n');
// Loop through the lines and print each one
for (var i = 0; i < lines.length; i++) {
// Trim leading/trailing whitespace and avoid printing empty lines
var trimmedLine = lines[i].trim();
if (trimmedLine) {
template.print(trimmedLine + '<br>'); // Use '<br>' for line breaks in HTML emails
}
}
} else {
// Optional: Handle the case when multilineText is empty or undefined
template.print('No data available.<br>');
}
})(current, template, email, email_action, event);