Reputation: 1122
I have a situation in NetSuite and don't know how to approach a solution.
We have Matrix Assembly Items (Clothing) each with child items. I'd like to watch for inventory changes on the child items, loop over all of the sibling inventory levels and get the inventory values, and then write a value to a field on the parent.
Basically, write to the field "colors_available"
Shirt (colors_available: Red, Blue)
Red - 203
Blue - 100
Red sells out:
Shirt (colors_available: Blue)
Red - 0
Blue - 100
Apologies for the lack of example code. I'm new to SuiteScript.
Upvotes: 0
Views: 634
Reputation: 915
If you are tracking the inventory changes, you need to deploy a user event script on transactions that will increase/decrease the item's inventory level. Then the script will check if the line item is a child matrix, so you can execute the logic to update the parent. This approach is better than schedule script, because it will be realtime.
Upvotes: 0
Reputation: 924
Ok.... this is complicated. First, there are two types of changes in NetSuite, first the standard ones like saving records and the second like matrix updates. Second ones don't trigger scripts at all, these are background single purpose processes. Your best option here is to run a scheduled script to check for inventory changes, and do the updates you want accordingly.
Upvotes: 0