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> </foreach>
Here you can find following important elements:
- ((Products.InventoryID)) – is link to the data view and field. You can use designer to insert fields like this using button “Insert” -> “Data Field”
- <foreach> – here it is the reserved word for the beginning of the loop
- 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.
- </foreach> – 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.
- 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)) </foreach>
- Second Step is to setup Notification and Approval workflow in the appropriate module settings.
- Third point is to create a claim and submit it. Please note that claim should meet your approval notifications.
- As soon as you submit a claim, notification should be generated and you can see it on the “Emails Pending Processing” or “All Emails”.
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.
<div> <foreach view="ExpenseClaimDetails"> <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> </span> </div> </foreach> </div>
Have a nice notifications!