Successfully written a custom GL script on item fulfillment to move COGS amount to another account desired by customer - first time using suitescript 2.1. However, I note the following behaviour and wonder if anyone can shed light on what is happening:
1. Script is running on CREATE and EDIT. I thought I read in the docs (or chatgpt, sorry I was desperate) it was only on the former. Can I or should I filter by event type?
2. The script appears to run twice on either of the above contexts. I thought it may have something to do with primary and secondary books, but logging the context object shows primary book in both instances. Script only needs to run once, I believe.
3. After adding the custom lines successfully, the custom lines object in the script is still showing zero lines if I edit the item fulfillment again: the standard lines object is unchanged, as expected. What I am trying to achieve here is to check if the custom lines have already been added, and if so, skip any update. Having said that, it seems to be managed already somehow because if I re-edit the record, multiple custom gl lines are not being added, as desired.
Thanks.