I spent way too much time fiddling with Sublist Action Groups, trying to get them to work. I finally broke down and created a workflow in our production NetSuite system. Then I submitted a case to NetSuite and let them give it a try. After another day of working together on the phone, fiddling, shockingly, it worked. Since I’m going to be doing a lot of these workflows, I didn’t want to lose this “magic!” So I’m writing it down.
Here is a summary of what I wanted to happen:
- I added a custom line item field called “Expected Ship Date.”
- When all the expected ship dates are populated (not empty), I want to send the customer an acknowledgment.
Here’s how this was accomplished. I started with a workflow that included 3 states.
I added a workflow field and set it to checked/true by default. This gets reset to true each time the workflow is entered. And it is important to note that since there is an exit point in the workflow, it re-enters this workflow each time a sales order is edited. I’ll talk more about that later.
When creating or editing a sales order, it enters the “Check each Line’s Exp Ship Date” state and executes a Sublist Action Group. By definition, a Sublist Action Group performs a series of conditions/actions on each sublist item. In this case, the sublist is “Items.” So the “Set Field Value” condition/action under it is performed on every sales order line item.
Since we’ve initially set the workflow variable “All Exp Ship Dates Present” to true/checked, if any line meets the criteria of “Is Empty”, it sets that variable to false/unchecked. I’m assuming this will fire as many time as there are empty “Expected Ship Dates”, but that won’t matter. You’ll see why below.
So I mentioned earlier that the workflow kicks off when a sales order is initially saved (created) or edited (subsequently saved). Note: I’m firing the sublist action group on “Before Record Submit.” The transitions execute on “After Record Submit.”
Since there are two transitions above that both fire on “After Record Submit”, it is very important to get their order of precedence correct. Whichever transition is first with a condition that evaluates to True sets the transition path.
And lastly, each time the state changes to “Exit” when a record is saved, the record changes from Edit mode to View mode. When the user re-enters Edit mode, the workflow starts over at Start. This resets the “All Exp Ship Dates Present” to true and everything begins again.
If the state changes to “All Dates Present”, it is very important to stop the workflow. Otherwise, it would continue to restart again and again even after all expected ship dates have been populated.
At this point in my workflow, I warn the operator that they need to notify the customer of when we expect their order to ship.