posting here also: <https://netsuiteprofessionals....
# suitescript
b
the absurd answer is that the customer payment template has access to the credits sublist
so you can make a template that has the credits sublist, then print it as html
which you can then programmatically access
j
the main issue is that I’m trying to write a bespoke “print payment as PDF/Excel/CSV” tool, because the built in template is crap and we cannot show what we need no matter how hard we try (and it cuts stuff off).
Not sure if above would allow us to get custom fields etc.
Do you happen to have an example of how to access the template via SuiteScript? Do you mean like generate the HTML using
render
then parse it for the details I need?
basically scraping the HTML?
b
i wasn't desperate enough to do it
j
oddly enough, that’s super hacky and appealing
I’m getting pretty desperate, have been trying to solve this for like two years now
I thought I could use nexttransactionlinelink and then compare timestamps and get the “additional” entries that way, but doesn’t work if you’ve applied a payment to an invoice from within another payment
@battk
record.credit
is coming out as blank/empty even though there are credits applied 😞
apply list works fine
my xml:
Copy code
<#if record.apply?has_content>
<apply>
<#list record.apply as apply>
<applied_to>
	<due>${apply.due}</due>
	<apply>${apply.apply}</apply>
	<currency>${apply.currency}</currency>
	<applydate>${apply.applydate}</applydate>
	<discamt>${apply.discamt}</discamt>
	<discdate>${apply.discdate}</discdate>
	<disc>${apply.disc}</disc>
	<internalid>${apply.internalid}</internalid>
	<trantype>${apply.trantype}</trantype>
	<total>${apply.total}</total>
	<amount>${apply.amount}</amount>
	<refnum>${apply.refnum}</refnum>
	<type>${apply.type}</type>
</applied_to>
</#list>
</apply>
</#if>

Credit:
#{record.credit}

<#if record.credit?has_content>
<credits>
<#list record.credit as credit>
<credit_applied>
	<due>${credit.due}</due>
	<apply>${credit.apply}</apply>
	<currency>${credit.currency}</currency>
	<creditdate>${credit.creditdate}</creditdate>
	<internalid>${credit.internalid}</internalid>
	<trantype>${credit.trantype}</trantype>
	<total>${credit.total}</total>
	<amount>${credit.amount}</amount>
	<refnum>${credit.refnum}</refnum>
	<type>${credit.type}</type>
</credit_applied>
</#list>
</credits>
</#if>
Calling it as follows:
Copy code
var xml_template = file.load({id: 17488240});
			
            var renderer = render.create();
            
            renderer.templateContent = xml_template.getContents();
            
            renderer.addRecord('record', record.load({
                type: record.Type.CUSTOMER_PAYMENT,
                id: payment_id
            }));
            
            var xml = renderer.renderAsString();
b
you need to use render.transaction
j
ahhh
is there a way to do that with a specified template, or will it automatically use the default template for that transaction? I don’t really want to mess with the existing template.
b
its a form thing
you select the form, which also chooses the template
j
ahhhh
so I can make a dummy form with my weird template, pass formid to render.transaction
cool
OK I’m getting closer, only thing I think I am missing is what the payment/credit is being applied to in the credits applied list.
b
its not there in the documentation but fair chance the data is just there and not documented
j
problem is guessing what it’s called
omg
it’s appliedto
this is gonna work
thank you @battk!