Enhancing Sales Order Workflow with Automated Discount Lines
Overview
The client required a Discount Line item to be added after each product line in a Sales Order (SO) under specific conditions. When the client created or edited a Sales Order, if the custom field “Discount Agency” had a value and the custom field “Discount Added” checkbox was unchecked, then a corresponding Discount Item had to be added after each product line in the sales order. Once the discount items were added for all the products, the “Discount Added” checkbox had to be checked.
Challenges Faced
- When a Sales Order (SO) is edited, if the “Discount Agency” has a value and the “Discount Added” checkbox is unchecked, the discount item is added again. This happens because the “Discount Added” checkbox is associated with the main line of the Sales Order, not with each individual line item.
- Whenever an existing line item is removed and the “Discount Agency” field is changed, then the Sales Order is saved again under the discount item adding condition. The Discount item should only be added for the removed line item.
Solution Offered by SuiteMatrix
- A user event script with a before submit function was created in NetSuite.
- The script is triggered upon the creation or modification of SOs.
- It checks for two conditions: whether the “Discount Agency” field contains a value and if the “Discount Added” checkbox is unchecked.
- Upon meeting these criteria, the script retrieves the corresponding discount item associated with the selected “Discount Agency.”
- It iterates through each product line in the SO, ensuring that a discount line is appended after each product line if it hasn’t already been added, thereby preventing duplication.
- Upon completion of processing all lines, the script updates the “Discount Added” checkbox to signify successful discount management within the Sales Order.
Results
The user event script effectively automated the addition of discount line items in SOs. This way, SuiteMatrix’s NetSuite consultants ensured an accurate discount application for the client. It dynamically verified conditions, retrieved corresponding discount items, and added them after each product line, preventing duplication. Challenges like managing new line items and field changes were adeptly handled. Upon completion, the script updated the “Discount Added” checkbox, streamlining discount management and enhancing workflow efficiency for the client.
No Comment