Contact Us

We use the ?eval_json tool in freemarker to create a variable that is parsed from the text in the field.

<#assign componentObj = record.custbody_ag_order_comp_details?eval_json />

In this example, componentObj is now an object stored as a freemarker variable. From here, you can dig down into the data as needed.

In this particular scenario, we wanted to loop through an array of objects.

example data:
componentObj = {
 items:[
   {datahere},
   {moredata},
   {moredata}
 ]
}
<#if componentObj?? && componentObj.items??>//check first if the data exists that we expect
   <#list componentObj.items as itemData>//the value of componentObj.items is an array.
       <tr>
           <th colspan="12">${itemData.name}</th>//pull values from the object defined as "itemData"
           <th colspan="4" align="center">${itemData.qty}</th>
           <th colspan="3">${itemData.units}</th>
           <th colspan="12" align="right">${itemData.description}</th>
           <th colspan="4" align="right">$${itemData.each}</th>
           <th colspan="4" align="right">$${itemData.bomCost}</th>
       </tr>
   </#list>
   </#if>


The biggest advantage of this method is that we can use the freemarker <#list></#list> construction to loop through the array and create a variable number of lines on the PDF, depending on the data stored in the custom field on the source record.

Got stuck on a step in this article?

We like to update our blogs and articles to make sure they help resolve any troubleshooting difficulties you are having. Sometimes, there is a related feature to enable or a field to fill out that we miss during the instructions. If this article didn't resolve the issue, please use the chat and let us know so that we can update this article!

Oracle NetSuite Alliance Partner & Commerce Partner

If you have general questions about SuiteCommerce or more specific questions about how our team can support your business as you implement NetSuite or SuiteCommerce, feel free to contact us anytime. Anchor Group is a certified Oracle NetSuite Alliance Partner and Commerce Partner equipped to handle all kinds of NetSuite and SuiteCommerce projects, large or small!

Horizontal Anchor Group logo orange anchor icon navy Anchor Group text

Tagged with Training