Hello! I'm trying to transform a multi-currency ve...
# suitescript
d
Hello! I'm trying to transform a multi-currency vendor bill into a vendor payment. What works: • I can create bills and turn them into payments if I don't set
currency
and
exchangerate
• I can create bills with a
currency
and
exchangerate
using suitescript regardless of the primary currency of the vendor, as long as the currency is in the vendor's
currency
list • I can pay bills via the UI regardless of the primary currency of the vendor. • I can transform bills to payments via suitescript if the
currency
is the same as the vendor
currency
(primary currency) What doesn't work: • I get the error: "You must enter at least one line item for this transaction" when transforming bills to payments if the vendor primary currency is different from the bill currency. Anyone have any ideas or can point me in the right direction to find an answer here?
a
Transform or create the record in dynamic mode and only set the currency, NetSuite should set the exchange rate dynamically.
🤔 1
d
Good idea - let me try that
Omitting
exchangerate
and using
isDynamic
doesn't change anything unfortunately
(it does set exchangerate automatically, which is nice, but doesn't fix my original issue)
b
what fields do you need to set to successfully create the payment in the ui
d
This is how I do it in the UI • Go to Transactions => Payables => Enter Bills => List • Select the bill • Click "Make Payment" • Change The Currency • Select an account • Click the bill under the Apply list • Hit Save That advice was helpful since When I don't click "apply", that's when I get the same "You must enter at least one line item for this transaction" error. How can I apply via suitescript? Does it have something to do with the apply sublist?
b
dynamic mode mimics the ui, so you would have to do equivalents for those actions in script
Copy code
Go to Transactions => Payables => Enter Bills => List
Select the bill
Click "Make Payment"
are all things that are handled by record.transform
so you would need to set the currency and then the account fields in script
and then set the apply field of the apply sublist for the line matching your bill
usually that means using Record.findSublistLineWithValue to find the line you are looking for
d
Any idea why I never needed to mess with the apply list before I started setting a currency?
b
observe what happens to the apply sublist when you change the currency field in the ui
d
I see. The correct apply is automatically selected upon transform if the currency of the bill matches the primary currency of the vendor
Thank you for the excellent help here! I think I can work with this
b
you may want to use the vendorbills default value depending on how good the solution needs to be
the apply sublist has a limit to the number of rows it can have
d
The problem is that there is no default value
That's why I'm getting that "You must enter at least one line item for this transaction" error
unless you mean the global default?
b
default value has a distinct meaning in the context creating records
i personally like the old name of transform values better
take a look at the parameters for record.transform
the
vendorbills
default value can be used to limit which transactions are allowed to show in the apply sublist
which should allow you to make the transaction you are looking for appear in the apply sublist even if there are thousands of rows normally
d
the
vendorbills
default value can be used to limit which transactions are allowed to show in the apply sublist
Can you expand on this? I see the
defaultValues
arg, but am not sure what I'd pass into it to make it apply to the correct bill
Would it be
{vendorbills: <id of the bill>}
b
its an array of internal ids
though you can just do a single internal id without the array
you can see how it works in the ui by using the default value as a query parameter in the url of the vendor payment
👀 1
d
I'm able to see it in the UI when I add vendorbills=12345 as a query param, but using it in
defaultValues
in suitescript doesn't work.
Copy code
record.transform({
            fromType: "vendorbill",
            fromId: "12345",
            toType: "vendorpayment",
            isDynamic: false,
            defaultValues: {'vendorbills': "12345"}})
gives me
Copy code
INVALID_RCRD_TRANSFRM: You have entered an invalid default value for this record transformation operation
I also tried
["12345"]
,
12345
, and
[12345]
Does it only work using
create
?
b
you will have to use record.create, your transform isnt actually selecting your payment, so you wont actually lose much
you would have to select the vendor in your code, just like you would in the ui
though there is a entity default value that you can use instead