Loops in Notification Templates

Hi Everone,

There is a nice functionality in Acumatica that allows you to print details of the document inside the notification template.
Acumatica Notification Templates

Together with other Data Fields, now you can put additional constructions like Loops (or for-each loops)

<foreach view="Products"> 
    ((Products.InventoryID)) - ((Products.Quantity)) - ((Products.CuryExtPrice)) <br> 

Here you can find following important elements:

  1. ((Products.InventoryID)) – is link to the data view and field. You can use designer to insert fields like this using button “Insert” -> “Data Field” Acumatica Notification Data Fields
  2. <foreach> – here it is the reserved word for the beginning of the loop
  3. view=”Products” – this is a view name that is used to get data from database. You can find a view name from “Inspect Ellement” customization tool or from other Data Fields. Data field has format like “((Products.Quantity))” – here “Products” is a view and “Quantity” is a field.
  4. </foreach&gt – is the reserved word fro the end of the loop. Everything what is between beginning and the end will be repeated by number of the details in the document.

You can read little bit more about it this functionality in the Acumatica help.
Note that you can use all possible HTML within a foreach loop.

Setting up approval notifications in Acumatica

Here I would like to share with you my own experiments. I wanted to print claim details inside standard notification template. To make it nicer I also added borders around lines and high-lighted the line amount.

  1. First Step is to Setup Notification Template. For the beginning you can use simple construction like this for details.
    <foreach view="EPExpenseClaimDetails"> 
        ((ExpenseClaimDetails.InventoryID)) - ((ExpenseClaimDetails.TranDesc)) - ((ExpenseClaimDetails.CuryExtCost))   

    Later you can do more experiments and make HTML nicer.
    Acumatica Notification Loop

  2. Second Step is to setup Notification and Approval workflow in the appropriate module settings.
    Acumatica Expense Claims Approval Notification
  3. Third point is to create a claim and submit it. Please note that claim should meet your approval notifications.
    Acumatica Submit Claims
  4. As soon as you submit a claim, notification should be generated and you can see it on the “Emails Pending Processing” or “All Emails”.
    Acumatica Expense Claim Email

Formating in the Loop

As soon as this is solved you can continue with some more nice experiments. Here I have tried to add borders and put every single line in the box with CSS styles. Border shadow is needed to collapse inner borders between divs.

     &lt;foreach view="ExpenseClaimDetails"&gt;
         <div style="border-width: 0px; border-style: solid; width: 700px;
		 		box-shadow: 1px 0 0 0 #888, 0 1px 0 0 #888, 1px 1px 0 0 #888, 1px 0 0 0 #888 inset, 0 1px 0 0 #888 inset;">
             <span data-field="yes">((ExpenseClaimDetails.InventoryID))</span> - 
			 <span data-field="yes">((ExpenseClaimDetails.TranDesc))</span> 
			 <span style="float: right;">
			     <span data-field="yes"><b>((ExpenseClaimDetails.CuryExtCost))</b></span>

Have a nice notifications!

Leave a Reply

Please rate*

Your email address will not be published. Required fields are marked *