On an SO, UE beforeSubmit if I getValue on "discou...
# suitescript
n
On an SO, UE beforeSubmit if I getValue on "discountrate" for a field that contains 10% it returns 10. For the same field if the user has entered 10 (as in £10, a static amount not percentage) the same getValue returns 10. It's worth noting I can do getText and see the % but that fails in some instances with the "_dreaded_" cannot getText on a field that has not been set with getText, also, via the console I can do getFieldValue (ss1.0) and see a full text version of the field including the %. Is it even possible in an SS2.0 UE script to ascertain if the discount is a percent or monetary amount? Bear in mind, if the discountitem selected is a percentage type discount the user can still override the value with a static monetary amount so looking at the rate on a discount item is also useless.
b
most obvious way would be to guess from the discounttotal
less obvious and something that can easily break is to use context.newRecord.toJSON() to get the discountrate
n
"guess", ugh, yeah not the kinda thing I can do with this but thanks for answering. I need to be able to either split the "total" across all lines on a per line basis if it's a monetary amount or a portion the percentage amount against each line. (i.e. if it's 20% across the board work out 20% on each line to populate a custom column) Curiously the way I ended up approaching it was to use JSON.parse()JSON.stringify(context.newRecord)) Hate the idea but better than guessing 😉
b
skip the parsing and stringifiying, directly use context.newRecord.toJSON()
although much more of a pain to use, you may want to use a line level discount item instead
especially if a subtotal item can work for you
n
lol the customer uses both. In the case of a line level discount I am copying the net / gross discount value to the line above 🙂 (don;t ask I'm not the customer!)
^^ in which case I'm not bothered if it's % or monetary value since that's already calculated by NS natively