Note – Before customizing/replicating the standard template check the feasibility of doing the same
To fetch Item Image and URL that comes under webstore subtab
/*Find the folder in file cabinet where the image from website is stored. You can go to an item, under webstore tab, associated images. This link will take you to file cabnet and find the folder in which it is stored*/
//Item Image search
function itemFileSearch(itemNumber) {
try {
let fileSearchObj = search.create({
type: "file",
filters:
[
["folder", "anyof", "4841"],
"AND",
["name", "contains", itemNumber]
],
columns:
[
search.createColumn({ name: "name" })
]
});
let searchResultCount = fileSearchObj.runPaged().count;
let imageUrl;
log.debug("fileSearchObj result count", searchResultCount);
fileSearchObj.run().each(function (result) {
imageUrl = result.getValue({ name: "name" });
});
log.debug("imageUrl", imageUrl);
return "--companyurl--/site/product-images/" + imageUrl;
}
catch (e) {
log.error("Error@itemFileSearch", e);
}
}
/*For most of the webstore items they will have the item url as website domain along with the value provided in urlcomponent field. Check how your url goes*/
//Item URL Search
function itemURLComponentSearch(itemInternalId, matrixType) {
try {
let itemRecordId = itemInternalId;
if (matrixType == "CHILD") {
let itemLookup = search.lookupFields({
type: search.Type.ITEM,
id: itemInternalId,
columns: ['parent']
});
itemRecordId = itemLookup.parent[0].value; // Get the parent item ID
}
let itemSearchObj = search.create({
type: "item",
filters:
[
["internalid", "anyof", itemRecordId]
],
columns:
[
search.createColumn({ name: "urlcomponent" })
]
});
let searchResultCount = itemSearchObj.runPaged().count;
let itemURL;
log.debug("itemSearchObj result count", searchResultCount);
itemSearchObj.run().each(function (result) {
itemURL = result.getValue({ name: "urlcomponent" });
});
log.debug("itemURL", itemURL);
return "--companyurl--" + itemURL;
}
catch (e) {
log.error("Error@itemURLComponentSearch", e);
}
}
Email Template
The highlighted part in email template is called to script in order to fetch item image and url displayed in the website

SuiteScript
Render the email template and replace the word that you specified in email template. Here, {{OrderSummary}} is replaced with a function
let itemObj = {
itemType: itemType,
amount: amount,
name: itemDisplay,
imageUrl: fileSearchResult,
urlComponent: urlComponent,
formattedOptions: formattedOptions,
giftCertRecipientEmail: giftCertRecipientEmail,
giftCertFrom: giftCertFrom,
giftCertMessage: giftCertMessage,
giftCertRecipientName: giftCertRecipientName,
quantity: quantity,
rate: rate
};
log.debug("itemObj", itemObj);
items.push(itemObj);
let emailTemplate = render.mergeEmail({
templateId: 35, //Replace template Id
transactionId: internalIdNumber
});
let emailSub = emailTemplate.subject;
let emailBody = emailTemplate.body;
emailBody = emailBody.replace('{{OrderSummary}}', generateOrderSummaryHTML(items));
Function
// Function to generate HTML for order summary table
function generateOrderSummaryHTML(items) {
let html = '<table style="font-family: Open Sans, Verdana, Arial, Helvetica, sans-serif; vertical-align: top; width: 100%;" cellspacing="0" cellpadding="0" border="0">';
items.forEach(function (item) {
html += `
<tr>
${item.itemType === "Discount" ? `
<td></td>
<td style="font-size: 12px; vertical-align: top;">
<div>
<span style="color: #81878c; text-align: left;">Coupon code applied:</span>
<span style="padding-left: 5px;">${item.amount}</span>
</div>
</td>
` : `
<td style="padding-top:10px;">
<img src="${item.imageUrl}" style="display: block; margin-left: auto; margin-right: auto; max-height: 64px; max-width: 64px;" alt=""/>
</td>
<td style="padding-top:10px;">
<div>
<a href="${item.urlComponent}" style="color: #087ca6; font-size: 14px; line-height: 16px; text-decoration: none;">
${item.name}
</a>
</div>
${item.formattedOptions ? `
<div style="font-size: 12px;">
${item.formattedOptions}
</div>
` : ''}
${item.giftCertRecipientEmail ? `
<div style="font-size: 12px;">
<span style="color: #81878c; text-align: left;">Recipient Email:</span>
<span style="padding-left: 5px;">${item.giftCertRecipientEmail}</span>
</div>
` : ''}
${item.giftCertFrom ? `
<div style="font-size: 12px;">
<span style="color: #81878c; text-align: left;">From:</span>
<span style="padding-left: 5px;">${item.giftCertFrom}</span>
</div>
` : ''}
${item.giftCertMessage ? `
<div style="font-size: 12px;">
<span style="color: #81878c; text-align: left;">Gift Message:</span>
<span style="padding-left: 5px;">${item.giftCertMessage}</span>
</div>
` : ''}
${item.giftCertRecipientName ? `
<div style="font-size: 12px;">
<span style="color: #81878c; text-align: left;">Recipient Name:</span>
<span style="padding-left: 5px;">${item.giftCertRecipientName}</span>
</div>
` : ''}
<div style="font-size: 12px;">
<span style="color: #81878c; text-align: left;">Quantity:</span>
<span style="padding-left: 5px;">${item.quantity}</span>
</div>
<div style="font-size: 12px;">
<span style="color: #81878c; text-align: left;">1 each:</span>
<span style="padding-left: 5px;">${item.rate}</span>
</div>
</td>
<td style="text-align: right; padding-top:10px;">
<span style="color: #4d5256; font-size: 14px; font-weight: 600;">${item.amount}</span>
</td>
`}
</tr>
`;
});
html += '</table>';
return html;
}