0
votes

I have created a custom Currency Record, and a single record for every currency in the system (cannot save a new record with same currency). For invoices, I need to source fields from this custom record based on the currency on the invoice.

For example if my invoice is in USD then I need to pull the "Bank Account #" field from the custom currency record where "Currency Name" field is "USD". I would assume I need to do a search and then pull this value, but I do not know the syntax for this with freemarker.

With Suitescript, I would have:

var currencyRecord;
var currency = nlapiGetFieldValue('currency');

var filters = new Array();
var columns = new Array();

filters[0] = new nlobjSearchFilter('custrecord_nco_currency_name', null, 'is', currency);
columns[0] = new nlobjSearchColumn('custrecord_bank_acct_num');
columns[1] = new nlobjSearchColumn('custrecord_nco_currency_name');

var currencyRecord = nlapiSearchRecord('customrecord_nco_currency_symbol', null, filters, columns);
2

2 Answers

4
votes

I don't think you can run searches using Freemarker. To my understanding the data needs to be living on the record or one level down. What you might need to do is create a custom body field of type List/Record>>(Your Custom Currency Record) and set up the Currency field as the source and then tinker around the filter settings so the field gets autopopulated based on the currency.

2
votes

You can use beforeload UserEvent with a type of 'PRINT'. Add a customfield to the body of the transaction or record that is not stored so you can us the beforeload script to populate the field with the data based on your logic. The data you populate the field with can be text or JSON, its up to the complexity you need.