Table -Pre-Totals Script to only Run Once

I have these two scripts on the SO Invoice Header running, one on a "table-pre-totals" and then another one on a "table-post-write" to reverse an action in the first script.  I am pretty sure when we open the batch up the "table-pre-totals" script fires off again because the other SO's are not being taken out of open sales orders, they still look like they need to be invoiced.  After accounting makes the edits they need to make on the invoice I need the "ApplyMultipleSalesOrder" field to go back to "Y" without trigger the pre-totals script again.

This is the link that is associated with this question, https://www.sagecity.com/us/sage100/f/business-object-interface/192828/button-option-on-so-invoice-entry-for-batched-orders