Infoplus offers custom email templates where users can setup canned or ad-hoc email templates. The following example profiles a client who used custom emails to create purchase order emails to their vendors. 


Custom email templates can be found by navigating to Apps > Emails > Email Templates, or searching via the quick action menu by pressing the period key.  


The use case below shows a client that used a custom template on their ASN table that is used to directly notify their vendors whenever a purchase order (ASN) is placed.  This client also submitted to the support team to get their email address verified on our servers. With this being done, they are able to enter their own emails as the Ship From contacts. 


In order to pull in vendor level information, a script is used to create a vendor object that can be referenced. You can see in the screenshot above that we are calling the script output in order to set the correct send to email address. In this case, the email will be sent to the contact email set in the order email field of the vendor record. 


Here is the finished result. The script and code for the body of the email can be found below.  





Here is the 'Script for ASN PO Email'  that makes this possible.  This script also exposes vendor data as well as creates an item map so we can return all line item information in a list format. 


// get vendor object
var vendor = infoplusApi.getById("Vendor", asn.vendorId);
output.put("vendor", vendor);

// query for all items on asn and put into map
var skuList = [];
for(var i=0; i<asn.lineItems.size(); i++)
{
    skuList.push(asn.lineItems.get(i).sku);    
}

var filter = "sku in ('" + skuList.join("','") + "')";
utils.log("Searching for items with [" + filter + "]");
var itemList = infoplusApi.search("item", filter, null, 250, null);

var itemMap = {};
for(var i=0; i<itemList.size(); i++)
{
    var item = itemList.get(i);
    utils.log("Found item [" + item.sku + "]");
    itemMap["sku_"+item.sku] = item;
}

output.put("itemMap", itemMap);



Here is the code for the body of the email. 



<table style="font-size: 12px; font-family: sans-serif; height: 50px; margin-left: auto; margin-right: auto;" width="750">
<tbody>
<tr>
<td style="text-align: center; vertical-align: middle;">
<h3><INSERT LOGO HERE<strong>&nbsp;&nbsp;</strong></h3>
<h2>PO #&nbsp;$record.poNo</h2>
<p>&nbsp;</p>
<p style="text-align: left;">Hello, this email is to inform you of an inbound purchase on behalf of INSERT VALUE. All pertinent information is provided in the body&nbsp;of this email.<span style="text-align: center;">&nbsp;</span><span style="text-align: center;">Please reply back to</span><span style="text-align: center;">&nbsp;</span><a style="text-align: center;" href="mailto:jolene@infoplus.com">jolene@infoplus.com</a><span style="text-align: center;">&nbsp;with any inquiries. Thank you for being a valued partner.&nbsp;</span></p>
</td>
</tr>
</tbody>
</table>
<table style="font-family: sans-serif; height: 40px; margin-left: auto; margin-right: auto;" width="750">
<tbody>
<tr>
<td style="font-size: 12px; font-family: sans-serif; margin-left: auto; margin-right: auto;">
<h4><strong>Shipping To:</strong></h4>
<h5><span style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; font-weight: 400;">#if(${scriptOutput.vendor})&nbsp;$!{scriptOutput.vendor.street2}&nbsp; -&nbsp;&nbsp;$!{scriptOutput.vendor.street}, $!{scriptOutput.vendor.city}, $!{scriptOutput.vendor.state} $!{scriptOutput.vendor.zipCode} #else N/A #end</span></h5>
</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<table style="font-size: 12px; font-family: sans-serif; height: 106px; margin-left: auto; margin-right: auto;" width="750" cellpadding="3">
<tbody>
<tr>
<td><span style="text-decoration: underline;"><strong>SKU</strong></span></td>
<td><strong><u>Item Description</u></strong></td>
<td><strong><u>Quantity</u></strong></td>
<td><strong><u>Price Each</u></strong></td>
<td><strong><u>Price Total</u></strong></td>
</tr>
<!--
         #set($total = $utils.newBigDecimal("0.00"))
         #foreach($lineItem in $record.lineItems)
            #set($item = $scriptOutput.itemMap.get($lineItem.sku))
            #set($quantityBigDecimal = "")
            #set($quantityBigDecimal = $utils.newBigDecimal($lineItem.orderQuantity.toString()))
            #if($lineItem.cost)
               #set($extended = $lineItem.cost.multiply($quantityBigDecimal))
               #set($total = $total.add($extended))
            #else
               #set($extended = false)</div>
            #end
      -->
<tr>
<td>$lineItem.sku</td>
<td>$lineItem.fullDescription</td>
<td>$lineItem.orderQuantity</td>
<td>&nbsp;<span id="autocomplete"><span id="autocomplete-delimiter">$</span></span><span style="text-align: right;">$utils.nvl($utils.formatMoney($lineItem.cost), "--")</span></td>
<td>#if($extended) <span id="autocomplete"><span id="autocomplete-delimiter">$</span></span>$utils.formatMoney($extended) #else -- #end</td>
</tr>
<!--
        #end
      -->
<tr>
<td style="font-weight: bold; border-top: 1px solid black;">Total</td>
<td style="font-weight: bold; border-top: 1px solid black; text-align: left;" colspan="4">$$utils.formatMoney($total) USD</td>
</tr>
</tbody>
</table>