I'm new to xml creating pdf doc ${record.somethi...
# advancedpdf
s
I'm new to xml creating pdf doc ${record.something} what is the technical term for this
a
bfo? freemarker?
s
im edit a template i found in netsuite
Copy code
!DOCTYPE pdf PUBLIC "-//big.faceless.org//report" "report-1.1.dtd">
s
big.faceless.org is commonly abbreviated as BFO. That is the engine that transforms HTML into PDF's. You need to have that declaration at the top in order for the template to be valid.
s
Is this JavaScript on ${record.something} ?
Like what if have record.item.cost. And I wanted only 2decimal points
s
No, it's not JavaScript. Almost all of the "programming" you can do in a template is through Freemarker, and the ${record.field} are just template tags for Freemarker to substitute dynamic values from the Netsuite record
s
Ok great thanks now I know where to look
s
For formatting number, you have two options: convert the value to a number then back to a string with the desired formatting via freemarker, or you can use NetSuite's custom formatting functions: https://netsuite.custhelp.com/app/answers/detail/a_id/26500#subsect_156624108232
when dealing with multiple currencies, NetSuite's functions will be better, but if everything is in one currency, either approach is fine
s
thanks for the help
at the current moment, we are calculating the amount of each item with qty * lpp for each line item how can I then get a total at the end?
Copy code
<#if record.item?has_content>

<table align="left" class="itemtable" width="100%"><!-- start items --><#list record.item as item><#if item_index==0>
<thead>
	<tr>
	<th colspan="8" style="align: left;">${item.item@label}</th>
	<th colspan="9">${item.description@label}</th>
	<th colspan="4" style="align: right;">${item.quantity@label}</th>
	<th colspan="4" style="align: left;">Country Origin</th>
	<th colspan="6" style="align: right;">${item.rate@label}</th>
	<th colspan="6" style="align: right;">${item.amount@label}</th>
	</tr>
</thead>
</#if><tr style="background-color: ${((item_index % 2)==0)?string('#ffffff', '#f0f0f0')};">
	<td colspan="8"><span style="color:#666666;">${item.item}</span></td>
	<td colspan="9"><span style="color:#666666;">${item.description}</span></td>
	<td colspan="4" style="align: right;"><span style="color:#666666;">${item.quantity}</span></td>
	<td colspan="4"><span style="color:#666666;">${item.custcol10}</span></td>  
	<td colspan="6" style="align: right;"><span style="color:#666666;">${item.lastpurchaseprice}</span></td>
	<td colspan="6" style="align: right;"><span style="color:#666666;">$ ${item.quantity*item.lastpurchaseprice}</span></td>
	</tr>
	</#list><!-- end items --></table>
</#if>

<hr />
<table align="left" border="0" width="100%"><tr>
	<td colspan="24">&nbsp;</td>
	<td colspan="6" style="align: right;"><b><span class="total">${record.total@label}</span></b></td>
	<td align="right" colspan="7"><b><span class="total">${record.total}</span></b></td>
	</tr></table>
s
what do you want the total of?
record.total
should already give the total of all line amounts. if you want to display a different value, you will need to calculate the sum yourself with a variable. https://freemarker.apache.org/docs/dgui_misc_var.html generally:
Copy code
<#assign t = 0>
<#list record.item as item>
    <#assign t = t + (item.quantity * item.lastpurchaseprice)>
</#list>
then display the variable where you want it to show up
s
record.total doesnt seem to work fro transfer order
s
yeah, different templates have different fields available, record.total is available in invoices and some other transactions, but if not available in the transfer orders, you can just use the variable summation approach
s
Thank you for these links great info
Copy code
${nsformat_rate(total, "USD")}
this still gives more than 2 decimals
s
That will follow the format defined for the currency in your environment
s
this is the output
Copy code
Total $31,527.57352212
s
If you go to https://acctID.app.netsuite.com/app/common/multicurrency/currency.nl?id=1 (Assuming USD is the first currency) what does it show for currency precision and format sample?
what, what is going on there? how is 32 being converted to 31,527.57352212 ? It's not even remotely close
have you tried using
${nsformat_currency(32)}
?
you shouldn't even need to pass in the currency, unless you want a different currency than is on the transaction
however that numeric conversion has more problems than just showing more than 2 decimal places, it's showing the wrong number entirely
s
my mistake it should say total
s
just wanted to make sure there wasn't something else going on. but definitely check on your currency formatting settings, as they do determine most of that behavior. alternatively, you can always go with
${total?string.currency}
or
${total?string[",##0.00"]}
s
how would i set this to a variable inside the list
Copy code
item.lastpurchaseprice
s
with assign:
<#assign lpp = item.lastpurchaseprice>
s
i did that it used the same for the whole list , let me try again
s
it should update on each iteration (for each item)
if it's not working, try declaring it before the start of the list:
<#assign lpp = record.item?first.lastpurchaseprice>
s
ok let me try thanks
s
though i don't think freemarker should need that
s
Copy code
<#assign lpp =  <#if item.lastpurchaseprice > 0><#else> item.rate </#if>>
s
you probably need to use the
condition?then(ifTrue, ifFalse)
directive, and also
gt 0
instead of `> 0`:
<#assign lpp = (item.lastpurchaseprice gt 0)?then(item.lastpurchaseprice, item.rate)>