Has anyone dealt with the 'You must enter at least...
# suitescript
c
Has anyone dealt with the 'You must enter at least one line item' error on a SuiteTax-enabled account when pre-populating a Vendor Bill via UE beforeLoad() ? Items are successfully added to the sublist via setSublistValue and are visible in the UI. • The Tax Details tab shows the correct Nexus and Subsidiary Tax Reg, but the Taxes sublist itself is empty. • On Save: NS throws the 'At least one line item' error. • If I manually click 'Preview Tax', the tax details populate and the record saves fine. It feels like beforeLoad isn't triggering the SuiteTax calculation engine, so the lines aren't being 'committed' internally. Is there a specific SuiteTax trigger field I should be toggling in the UE to force that calculation without needing the manual UI click?
b
this might be the first time a record macro is the suggested solution. Execute the record macro that corresponds to the Preview Tax button
that said, I would expect this to fail. You are supposed to use the pageInit entry point to source records.
c
Without SuiteTax, I'm sure I can create line items, set a tax code, then the user can save the record.
If I move this to a ClientScript, the UI hangs while it waits for the script to execute; it's not the best user experience.
a
The UI would only hang if you don’t use promises.
c
Making it non-blocking was also a user experience disaster. Users started to input data into fields which would get overwritten when the promise returns. With some better training though, this could still work.
e
@Craig Add a fullscreen modal (We are calculating your taxes ... or it is loading ...) to block user interaction in case you can know once the promise is returned.
c
I'm not even sure this will work with a ClientScript. I'm not clear how to trigger SuiteTax calculations.
I will try though but there must be a way to do this with server side script otherwise a lot of customisations will break if you're using SuiteTax
b
record macros are equivalent to pressing buttons
👍 1
c
But aren't they client side only?
e
It seems @battk is on the right track. This is what you are looking for: https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/section_1565108575.html the macros are client and server side, another link says that.
c
Thanks for the link, I could not find that despite searching.
Specifically deals with SuiteTax calcs from SS.
"The SuiteScript 2.0 N/record Module module includes the Record.executeMacro(options) method." Amazing, thanks.
e
I have worked on this from SuiteCommerce side, so I had an idea where to look for. Let us know how you solved.
c
Going to test if it can be run from beforeLoad. Crossing my fingers.
It's not clear to me why this is even needed really.
If I add the item from the UI, taxes are calculated on save. If I add the item from SS, I get the At Least One Line Item error instead of calculating on save.
b
fields set in the beforeLoad dont trigger field sourcing. You can get away with using a beforeLoad for setting simple fields (like memo) but will fail for fields that trigger lots of sourcing.
For example, setting the entity on a sales order will not source in the default billing address or shipping address. Or more crippling, no subsidiary
e
I think you need to execute this by yourself on-demand, from a webstore, there is a module that calculate taxes executing this Suite-Tax engine (when enabled) but I noticed that after placing an order, the cart was empty but there was no validation to execute again the API for SuiteTax, so in that specific moment, I get an error that I was trying to calculate taxes on an empty cart. I know you are not working on SuiteCommerce but your error message remind me that scenario.
b
You are much less likely to get away with setting line items on a beforeLoad script, there is a lot of sourcing going on in the primary sublist of a transaction
c
Yeah, that's why I'm probably going to port this whole thing over to a ClientScript.
With attention to the impact on the UI, blocking, and user data getting overwritten.
Thanks.