Custom Margin Report in NetSuite


One of our American clients, who is into Industrial Hardware, had a customization requirement in NetSuite to generate a custom “Margin Report.”


Our client required a Margin report on the following Transactions: 

Sales Orders,  

• Cash Sales,  

Purchase Orders 

• Bills, and  

• Invoices. 

The  report needed to contain the item name and transaction details including – Quantity, Date, Document Number, Document Type, Document Status, Amount per item, Ship Date, Sales Rep, Vendor, and Manufacturer.  


Adding Purchase order related Records

Our developers approached the requirement by running a script to find out related sales orders of vendor bill and bill payment. They attached these details to the “SO (Sales Order) Related records” tab in the sales order. Importantly, this is exclusive to dropship Purchase Orders only.

Generating Margin Report

We began by creating a custom page for the “Margin report”. From this page users can generate the margin report based on filters and download the generated report. 

The margin report custom page will have the following elements:

Filters: Sales Order Date, Tran date, Ship Date (start date and end date)

Button: “Generate report”

On the Margin report page, users can add the necessary filters and click on the “Generate Report” button on the page. On the button click trigger, we created a custom record to store the request, and based on that we initiated another backend scheduled script that generated  the report in the background.  

Further, we sent the report to the logged user along with the file link and by clicking the link the user can download the report. Our developers made use of a scheduled script to implement this.


Our client was satisfied with the Margin Report as they can now seamlessly review  reports by altering the filters and make use of the data easily.