When setting lines in an item sublist, how can I g...
# suitescript
t
When setting lines in an item sublist, how can I get the amount to populate from the rate? On the first line I set an item, quantity, amount. For my 2nd item, I need to set like -20% in the rate. When I do it in the UI, netsuite automatically calculates what the amount is. Doing it through a standard or dynamic record never seems to populate it, always saying I need to set the amount.
k
have you set a quantity? amount is rate * quantity
t
These are discounts so quantity isn't allowed for these items. When I fill it out manually in netsuite, I can just type in -20% in the rate and it'll autopopulate the amount to be -20% of the item above
Even when I tried setting the quantity through code, it didn't change anything
k
if i had to guess, i'd think that in the webface, it goes like this: • set rate and quantity • amount gets calculated • set discount • amount gets changed so, you'd have to either use dynamic mode and reproduce the "steps you would take in the ui", or just do the math yourself (which, when involving currency calculations, may warrant some care)
i just tested a thing for unrelated reasons, and rate appears to be completely decoupled (at least in standard mode) from amount. i was able to set a rate of 0.01 and an amount of 35 and it didn't recalculate or care
this makes some amount of sense if you read it as "rate is the unit price, amount is what we charged/will charge"
t
I am also trying it in dynamic mode but it always errors on the commitLine because there's no amount. Im fairly confident I can just calculate the math myself, percent * amount, because I don't see anything currency related on the line level. It's just really odd, I expected this to at least function the same as the UI
And yea the order I'm doing when testing is setting the first line: item, quantity, rate, amount. Then 2nd line: item, rate and it doesn't update.
k
i hear you 😅 i find this whole process incredibly frustrating
i think there's some frontend JS doing some of this logic in some places
so it may be unavoidable to do the math yourself. but i don't know things deeply, so i hope someone else can answer you more clearly
t
Thanks for helping still. I tried a lot of things anyways and nothing got the amount to automatically update so far, so at this point I'll just end up doing the math. For the time being at least it's just percent * amount If it changes in the far future, well none of those fields like currency or conversion rate even exist at the moment so I don't think I can do much there
r
You can set a custom price level for that line, add in a discount item with calculated discount amount, or add in a promo. If you have the logic in handy. Create auto promos might do the job tbh.