on a client script, how would i determine if a lin...
# suitescript
n
on a client script, how would i determine if a line is being added or updated? For example, if a user creates a new line on item sublist and selects "Add" I want to add another line with a set item. But if they are just modifying an existing line i don't want the new line added.
t
you can catch the new line item using the clientscript "validateLine"
n
@Tyn Guardian unfortunately it fires on both new line and updating lines.
t
you can return false if you dont want the entry to be saved
n
right but how do it tell the difference between a new line and a line that is just being updated
t
well there is a validateInsert for new item
n
hm for some reason I can't get validateInsert to fire when i add a new line
it only fires if you click the "+ Insert" button not when you click "Add"
s
I have an idea, but it might not be the right solution You could loop the lines and store it as a global variable/constant during pageInit, then check against this with validateInsert/balidateLine
you might want to store, itemId, line, lineId etc
i'm gonna say safest is probably still a UE on after submit and you do oldRecord vs newRecord, that's what I'd try
e
I'd just track the line count from currentRecord
n
@ehcanadian @Sciuridae54696d great ideas, thanks!