Requirement
Team Vita wants to automate the line-level location population when the sales order status changes to Pending Approval to Pending Fulfillment. The line level location will change based on the Order Type.
Our Solution
We can automate the line level location population in the sales order by using a suite script. We can check if there is any existing script where we can incorporate the new updates. Otherwise, we can create a user event script for updating the status. The script will trigger the status change of Pending Approval to Pending Fulfillment.In the script, we can use the logic which is given below,
We can use any existing differentiation or create a custom field for checking if the order is a Costco USA order or not. If the order is a Costco USA order, We can check the Costco USA “virtual” warehouses (3) otherwise we can check the non-Costco USA “virtual” warehouses (3). Users need to update the values at the time of sales order creation. If not, is there any other way to verify the order is from Costco USA or not?.
We can create a new custom record for storing the State based warehouse locations and by using that we can find the warehouse from the shipping state. In our custom record, we can store the 3 immediate warehouse states. So if the corresponding warehouse stock is empty we can check the immediate warehouse.
We can check the order shipping state and based on that we can fetch the corresponding warehouse. Then we can check if the warehouse has stock to fulfill the order and if the warehouse has enough stock we can set that warehouse as location. Otherwise, we need to check the stocks of immediate warehouses.
Custom Record Fields
| Is Costco USA or Not | State | 1st Immediate | 2ndImmediate | 3rdImmediate |
| The custom field for checking the order type. | The corresponding state for the shipment | If the state warehouse is without stoke, we will consider this as the next state. | If the 1st immediate state warehouse is without stoke, we will consider this as the next state. | If the 2nd immediate state warehouse is without stoke, we will consider this as the next state. |
We need CSV import as a one-time setup for creating custom records for the state warehouses.
Assumptions
- The script will trigger only when the sales order status is changed to pending fulfillment.
- Sales order location is fetched based on the shipping state/province location.
- The state and warehouse is fetched from the images that you have provided earlier ans setup custom record based on this.