Hello, I have a question. Is it possible to compa...
# suitescript
p
Hello, I have a question. Is it possible to compare an old field value to a new field value in a validate line function?
b
nope, you would have to do something with fieldChanged or postSourcing
if it only needs to support edits, you might be able to get away with loading the old record
p
what do you think is the easiest way get the old value and then compare it to the new value? I also need to keep track of the old and new value
b
depends on what you mean for the old value
p
I need to track when the amount field is adjusted on a line
b
thats going to be painful
that field changes when quantity or rate changes
it probably even changes when an item is selected
a naieve solution is to put a fieldChange/postSourcing functions to track when the amount changes
its naieve since someone can innocently change the item to something else and that will count as a change
same thing for changing the quantity, the rate, price level, or any of the other things that can change amount
so be very specific about what you want to track, lots of things can cause the amount field to change
p
is it easier to track itemrate?
whats the best way to script if the rate changes?
b
not especially, same problems
p
I need to write the old and new value
b
define what old value means in the context of creating a new record
everything is new
p
if the user goes to the line and changes the rate for the item
I only want to track if the user edits the line
b
suitescript offers no solution to track if a user edits a field vs a script, or netsuite itself
you can try using javascript (potentially relying on events), but again, painful
p
What's the actual requirement? You want to store the old value when the record is saved? You want to stop something happening before the record is saved, based on the old and new values? You want to stop the line actually being modified at edit time, depending on some logic involving the old and new values? Or something else? Be explicit about what you're trying to achieve, rather than what you're developing
p
PNJ, I am looking to store the old value when saving