How do I trigger committing a sublist line only if...
# suitescript
w
How do I trigger committing a sublist line only if it's been modified? I want to do the same thing that the 'Save' button does, but if I just blindly call commitLine() then if the line is blank it complains about validation since obviously none of the required fields are filled in.
b
More context required
Have you added some sort of button. Whats triggering your commitLine
w
Yes, this is triggered from a button
The idea is that it does some manipulation of the items on a sales order (adding markup items if necessary) but this doesn't work right if the button is clicked while there's a line item that hasn't been committed.
b
i dont suppose you can just be mean and cancel the current line and then do your logic
the alternative is a client script that keeps track of changed lines in the fieldsChanged and sublistChanged entry points
w
Yeah, I'd rather not just cancel the line item. I was hoping there was a call I'd overlooked like record.isLineChanged() but I guess not. Thanks for the advice.
After discussing it I ended up committing the line if it has an item filled in, otherwise cancelling. That way it takes care of the main case of filling in the whole thing but forgetting to hit add, without adding a big pile of logic around keeping track of if it's been modified.