This is a FreeMarker email template in NetSuite ta...
# ask-stanley-ai
n
This is a FreeMarker email template in NetSuite targeting a custom record type that contains related items through the field
custrecord_rfql_lines
. Although the
record
object is present and renders, the item lines are not shown in the output. Template code:
Copy code
freemarker
Th
Beschikbare root keys:<br/>
<#list .data_model?keys as key>
  ${key}<br/>
</#list>

<#if record?? && record.custrecord_rfql_lines?? && (record.custrecord_rfql_lines?size > 0)>
  <#list record.custrecord_rfql_lines as line>
    ${line.custrecord_item} - ${line.custrecord_quantity_requested} x ${line.custrecord_description}<br/>
  </#list>
<#else>
  Geen regels gevonden.
</#if>
Actual output:
Copy code
perl
is
Beschikbare root keys:
companyinformation  
customRecord  
customRecord@title  
message  
nsfont  
nsformat_boolean  
nsformat_checkbox  
nsformat_currency  
nsformat_date  
nsformat_datetime  
nsformat_email  
nsformat_number  
nsformat_password  
nsformat_percent  
nsformat_rate  
nsformat_time  
nsformat_url  
nstranslation  
preferences  
Transaction  
Transaction@title  
user  
Geen regels gevonden.
The custom record is loading correctly, and the email renders without errors. However,
custrecord_rfql_lines
appears empty in the template even though it contains values when viewed in the UI. It’s unclear whether
custrecord_rfql_lines
is a sublist, subrecord, or a multi-select/multi-record field. How can I properly access and display the values in
custrecord_rfql_lines
in this FreeMarker context? Is there a required structure or method for referencing such related data in NetSuite email templates?
c
AI generated answer (using internal Slack threads):
Based on the conversations, it seems that the issue is related to accessing sublist or subrecord data in a FreeMarker email template in NetSuite. The
custrecord_rfql_lines
field might be a sublist or a subrecord, and it's not directly accessible in the FreeMarker context. In NetSuite, sublists or subrecords are not directly accessible in the FreeMarker context. You need to manually add the sublist or subrecord data to the data model that is passed to the FreeMarker template. This can be done using SuiteScript before the email is sent. Here is a general approach to solve this issue: 1. Use SuiteScript to load the custom record. 2. Get the line count of the
custrecord_rfql_lines
sublist or subrecord. 3. Loop through each line and get the field values you need (e.g.,
custrecord_item
,
custrecord_quantity_requested
,
custrecord_description
). 4. Add these field values to an array or object. 5. Add this array or object to the data model that is passed to the FreeMarker template. 6. In the FreeMarker template, loop through this array or object to display the sublist or subrecord data. Here is a pseudo code example:
Copy code
javascript
var customRecord = record.load({
    type: 'customrecord_my_custom_record',
    id: '123'
});

var lines = [];
var lineCount = customRecord.getLineCount({ sublistId: 'custrecord_rfql_lines' });

for (var i = 0; i < lineCount; i++) {
    var item = customRecord.getSublistValue({ sublistId: 'custrecord_rfql_lines', fieldId: 'custrecord_item', line: i });
    var quantity = customRecord.getSublistValue({ sublistId: 'custrecord_rfql_lines', fieldId: 'custrecord_quantity_requested', line: i });
    var description = customRecord.getSublistValue({ sublistId: 'custrecord_rfql_lines', fieldId: 'custrecord_description', line: i });

    lines.push({
        item: item,
        quantity: quantity,
        description: description
    });
}

var dataModel = {
    record: customRecord,
    lines: lines
};

var emailBody = render.freemarkerTemplate('my_template', dataModel);
In the FreeMarker template, you can then loop through the
lines
array:
Copy code
freemarker
<#list lines as line>
  ${line.item} - ${line.quantity} x ${line.description}<br/>
</#list>
Please note that this is a general approach and the actual code may vary depending on your specific requirements and NetSuite setup. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.851824343
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.840422332
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.832390189
Please provide your feedback on this answer.