ANS-0513 · CUSTOM FIELDS, RECORDS & FORMS
How to Dynamically Calculate and Apply Surcharges on NetSuite Invoices Using Workflows
Learn how to implement a dynamic surcharge on NetSuite invoices that updates automatically based on line item values and project-specific percentages, ensuring accurate calculations before record submission.
Short answer
To dynamically calculate and apply surcharges on NetSuite invoices before record submission, leverage workflow fields and sublist action groups. This approach involves creating workflow fields to sum relevant line item values and count existing surcharge lines, then using set field value actions and sublist action groups to update the surcharge amount and add or modify the surcharge line based on these calculations.
Scenario
Organizations often need to apply a surcharge to invoices, calculated from the sum of specific line item values multiplied by a percentage defined on the associated project record. This surcharge must also dynamically update if the invoice lines are edited after initial creation. A common challenge arises when initial solutions, such as using saved searches, are unsuitable because calculations must occur before record submission, a limitation for saved search-based computations.
Solution
To implement this dynamic surcharge calculation and application, utilize NetSuite workflows with sublist action groups and workflow fields. The process involves the following steps:
Create a workflow field for the Total Professional Fees to store the cumulative amount from relevant lines.
Create a workflow field for count of surcharge lines to track the number of existing surcharge items on the invoice.
Implement actions to set both the Total Professional Fees and count of surcharge lines workflow fields to 0 at the beginning of the workflow execution, ensuring calculations are always fresh.
Create a sublist action group containing two actions:
- Set the Total Professional Fees workflow field to its current value + the line amount, conditional on a specified custom field on the line matching a target value.
- Set the count of surcharge workflow field equal to itself + 1, conditional on the item being the designated surcharge item.
Create a Surcharge Amount field. Use a formula in a set field value action to set this field equal to the Total Professional Fees workflow field X the project field.
Create an Add Line field with the condition that the count of surcharge items workflow field is greater than
Configure this action to set the item to the surcharge item, the quantity to 1, and the rate to the Surcharge Amount workflow field.
Create another sublist action group with the condition that the count of surcharge items workflow field is equal to
Within this group, add one set field value action with a condition that the item (line) is the surcharge item, and set its rate equal to the surcharge amount workflow field.
Expert NetSuite Support
Need help with this NetSuite issue?
Custom Fields, Records & Forms consulting and configuration support
