I'm looking for a way to validate item lines on a ...
# suitescript
e
I'm looking for a way to validate item lines on a Sales Order that's been copied. I have a script in place that determines if the SO has been copied, but if I try to loop through each line and select then commit the line... any pop ups like low inventory warnings prevent the loop from continuing. Any way to work around this?
c
Do you actually need to make any changes to the lines?
a
Maybe disable inventory warnings in home > set preferences > transactions? I'm not sure how you can do it company wide.
e
@CD Don't need to make changes to the lines We have some items that shouldn't be added to SOs... but they were on SOs in the past. So there is a validateLine script that throws warnings if a user tries to add these items to an SO. Butttt the validateLine script doesn't trigger if the user copies an old SO. So the goal is - when a user clicks save on a copied SO, a script will loop through each line and trigger the validateLine script and throw a warning if the item isn't supposed to be on an SO
b
that sounds slow, i say adapt the logic of the validateLine script to work with CurrentRecord.getSublistValue and use that in the saveRecord
e
Are you saying, rather than loop the lines and trigger the validateLine script, just loop the lines and run the logic that exists within in the validateLine script? (which in this case is just a search.lookUp that checks the value of a custom checkbox called "Not for Sales Orders")
@battk
b
its more likely that you will have to refactor your validateLine in some way
it probably uses getCurrentSublistValue, which wont be useful in saveRecord
e
Good point. Id agree that this is a better approach. I can also "store" any issues and display them all in one pop up once the loop is complete like "Lines 2, 3, and 5 contain items that shouldn't be added to Sales Orders anymore"
b
it probably allows you to do the optimization of doing one search for all your lines vs one lookup per line
e
The optimization being that doing one search.run() would be far less governance than the search.lookup() * number of item lines, right?
b
yes
🍻 1
alternatively, if your lookup is easy, you may be able to just use sourcing on a custom transaction line field to avoid searching at all
e
I appreciate the insight @battk