- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2023 10:04 AM
Hello,
I attached 2 images in the Catalog Item. However, when I receive the email, the images are showing side-by-side.
Is it possible to fix the following code to show images one on the top and other at the bottom? Thank you
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
var gr = new GlideRecord('sys_attachment');
gr.addQuery('table_sys_id', current.sys_id);
gr.addQuery('content_type', "CONTAINS", "image");
gr.query();
while (gr.next()) {
template.print("<img width='500' height='200' src=/sys_attachment.do?sys_id=" + gr.getValue('sys_id') + ">");
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2023 10:17 AM
Hi @Jessica28 ,
Try to add line break tag inside the while.
while (gr.next()) {
template.print("<img width='500' height='200' src=/sys_attachment.do?sys_id=" + gr.getValue('sys_id') + ">");
template.print("<br>");
}
-Thanks
Ashish
Please accept solution and helpful for others if it helps you
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
11-07-2023 10:20 AM - edited 11-07-2023 10:22 AM
Hi @Jessica28 ,
Hope all is well. Try adding a line break in the code and let me know your luck.
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
var gr = new GlideRecord('sys_attachment');
gr.addQuery('table_sys_id', current.sys_id);
gr.addQuery('content_type', "CONTAINS", "image");
gr.query();
while (gr.next()) {
template.print("<img width='500' height='200' src=/sys_attachment.do?sys_id=" + gr.getValue('sys_id') + "><br>"); //add <br> between images
}
Kind regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2023 11:22 AM
Please update your script to something like this.
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
var gr = new GlideRecord('sys_attachment');
gr.addQuery('table_sys_id', current.sys_id);
gr.addQuery('content_type', "CONTAINS", "image");
gr.query();
while (gr.next()) {
template.print("<div><img width='500' height='200' src=/sys_attachment.do?sys_id=" + gr.getValue('sys_id') + "></div><br/>");
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2023 10:17 AM
Hi @Jessica28 ,
Try to add line break tag inside the while.
while (gr.next()) {
template.print("<img width='500' height='200' src=/sys_attachment.do?sys_id=" + gr.getValue('sys_id') + ">");
template.print("<br>");
}
-Thanks
Ashish
Please accept solution and helpful for others if it helps you
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
11-07-2023 10:20 AM - edited 11-07-2023 10:22 AM
Hi @Jessica28 ,
Hope all is well. Try adding a line break in the code and let me know your luck.
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
var gr = new GlideRecord('sys_attachment');
gr.addQuery('table_sys_id', current.sys_id);
gr.addQuery('content_type', "CONTAINS", "image");
gr.query();
while (gr.next()) {
template.print("<img width='500' height='200' src=/sys_attachment.do?sys_id=" + gr.getValue('sys_id') + "><br>"); //add <br> between images
}
Kind regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2023 11:22 AM
Please update your script to something like this.
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
var gr = new GlideRecord('sys_attachment');
gr.addQuery('table_sys_id', current.sys_id);
gr.addQuery('content_type', "CONTAINS", "image");
gr.query();
while (gr.next()) {
template.print("<div><img width='500' height='200' src=/sys_attachment.do?sys_id=" + gr.getValue('sys_id') + "></div><br/>");
}