I'm trying to stop an item being entered on a Sale...
# suitescript
t
I'm trying to stop an item being entered on a Sales Order Line Item based on an arbitrary value; I'm currently using a fieldChanged event on a SS2.0 Client script to detect when an Item with the appropriate value is entered on the Line Item - what would be the best/least obtrusive way to stop the value from being entered? I first tried returning false in the event but that didn't work, then tried to setValue to null but that causes the Item field to lose focus. Any ideas on ways to prevent the value from being entered while keeping focus on the Item field?
b
use the validateField entrypoint
t
What is the benefit with validateField over fieldChanged?
its designed to do what you are trying to do
t
That's perfect, thank you!
a
I would use
validateLine
But
validateField
is specially designed for your use case…
z
@alien4u I prefer validateLine too, but the end user typically doesn’t because they go through the work or putting in the item, quantity, location and whatever else and then get blocked from adding it when they go to the next line
t
Would either validateField or validateLine allow me to return false to reject an input?
a
@Zack Agree, that is the bad and also good thing, after the user goes through that a couple of times he/she will remember to not do it…
z
Haha I just prefer not to have any client side logic running on lines. It slows stuff down so fast on some computers
t
Update: it does allow me to return false 🙂
Thanks everyone for the advice