Show Total Item Quantity on a NetSuite Sales Order

Add a Total Line Quantity field to NetSuite sales orders by pointing a non-stored custom body field at a summary saved search that sums line quantities.

The quick answer

NetSuite has no standard header field that adds up a sales order's line quantities. You can make one without a script. Build a Transaction saved search that sums Quantity over Sales Order item lines and has Internal ID under Available Filters. Then create a transaction body field with Store Value cleared and select that search under Validation & Defaulting > Search, leaving Field blank. When an order loads, NetSuite passes its internal ID into the search, so each order shows the total of its own saved lines.

The screenshots show sample data. Person and company names are fictional. Use your own names and values when following the steps.

Before you start

In this example, Alex Morgan is an Administrator at Example Supply Co. A warehouse lead wants the number of units on each order visible at the top of the page. There are three open orders:

  • SO-4118 for Brightwater Dental Group: Task Chair 5, Folding Table 10, Mobile Whiteboard 2. That's 17 units.
  • SO-4121 for Lakeview Learning Center: Task Chair 8, Storage Cabinet 4. That's 12.
  • SO-4124 for Pinecrest Veterinary: Folding Table 6, Mobile Whiteboard 1. That's 7.

You need permission to create saved searches and transaction body fields. If your team uses a custom Sales Order form, you also need to be able to edit it. The people who will see the field need access to the saved search and to Sales Orders. Role permissions and subsidiary restrictions can also keep the value from showing, so test with the roles that will use it.

A field like this has limits. It's normally recalculated from saved data each time an order loads, so it doesn't count lines you're adding in edit mode, and it isn't stored on the transaction. Those limits are covered at the end of step 05.

01. Check the order lines

Open SO-4118 in view mode. The header has Order #, Customer, Date, Posting Period and the Summary box, but nothing that counts units. Scroll to the Items subtab. The Quantity column shows Task Chair 5, Folding Table 10 and Mobile Whiteboard 2. They add up to 17, and that number isn't anywhere on the page.

SO-4118's lines: 5 + 10 + 2 = 17 units, with no field showing that total.

Do the same on the other two orders so you know what to expect later. SO-4121's lines add up to 12 and SO-4124's to 7.

Go to Lists > Search > Saved Searches > New and choose Transaction. Enter the Search Title Sales Order Line Quantity Total (field source, do not edit) and the ID _so_line_qty_total. NetSuite adds the customsearch prefix when you save. Check Public so the people who set up and view the field can use the search. You can share it on the Audience subtab instead.

The title says "do not edit" for a reason. Anyone who changes this search changes the field on every order immediately.

On Criteria > Standard, add these filters:

  • Type is Sales Order
  • Main Line is false
  • Tax Line is false
  • Shipping Line is false
  • COGS Line is false, if your account offers it

Main Line is false drops the order header row and keeps the lines. The tax, shipping and COGS filters drop generated rows that aren't item lines. Check the preview in the next step before you trust the total.

These criteria drop the order header row and the tax, shipping and COGS rows.

On Results > Columns, click Remove all. Add Quantity and set its Summary Type to Sum. Keep it as the only column. A body field needs one value back, and a single summarized column with no Group column gives you exactly one row.

One result column: Quantity, summarized as Sum.

On Available Filters, add Internal ID. Don't skip this one. Without it, the search doesn't show up in the body field's Search list at all. It's also how the field gets the right order: NetSuite passes the displayed order's internal ID into this filter.

Internal ID under Available Filters. Without it, the body field can't select this search.

Don't add a criterion like Internal ID is 123 instead. That pins the search to one record, and every order would show the same number.

Click Save & Run. The results page has one row, Sum of Quantity 36. In this example account that's 17 from SO-4118, 12 from SO-4121 and 7 from SO-4124. Run on its own, nothing is passed into the Internal ID filter, so the search adds up every matching Sales Order line in the account. In a real account the number will be much bigger.

On its own, the search returns 36: all three orders added together.

Use this preview to check the criteria. If the total is higher than the lines you expect, look for tax, shipping or COGS rows that slipped through.

04. Create the body field

Go to Customization > Lists, Records, & Fields > Transaction Body Fields > New. Enter the Label Total Line Quantity and the ID _so_line_qty_total. Set Type to Integer Number. Use Decimal Number instead if your quantities can be fractional. Clear Store Value. On Applies To, check Sale.

Integer Number, Store Value cleared, and Sale checked on Applies To.

Sale covers other sales transactions too, such as invoices and cash sales. The search only looks at Sales Orders, so the field can show up blank on those. Hide it on those forms if the blank will confuse people.

On Display, set Subtab to Main. The field then sits with the header fields above the subtabs instead of on its own subtab. Its exact position depends on the form.

Subtab Main puts the field in the header area.

On Validation & Defaulting, leave Default Value empty. In Search, choose Sales Order Line Quantity Total (field source, do not edit). Leave Field blank. With Field blank, NetSuite passes the current order's internal ID into the search's Internal ID filter.

Search selects the saved search. Default Value and Field stay empty.

If the search isn't in the list, go back to it and check two things: Internal ID is under Available Filters, and the search is public or shared with your role.

Click Save. If your team uses a custom Sales Order form, choose Save & Apply to Forms instead and make sure the field is shown on that form. The Transaction Body Fields list shows the saved ID, custbody_so_line_qty_total.

The saved field: custbody_so_line_qty_total, Integer Number, on the Main tab.

05. Open the order

Open SO-4118 in view mode again. Total Line Quantity now shows 17, the 5 + 10 + 2 from its own Items lines. It isn't the 36 the search returned on its own, because the order's internal ID went into the Internal ID filter.

SO-4118 shows 17, matching its three item lines.

Because Store Value is cleared, NetSuite runs the search when the saved order loads. A few things follow from that:

  • Lines you add or change in edit mode aren't counted until you save and reload the order. A new order has no value until it's saved. If you need a live total while editing, that takes a script.
  • The value isn't saved on the transaction, so don't count on it in saved search criteria, list columns, CSV exports or printed forms. If you need it there, store it with a workflow or script, or calculate it in the search or template itself.
  • Quantity is in transaction units. Kits and items with units of measure can make one number ambiguous, so decide whether you want units as sold or physical component units.

06. Check a second order

Open SO-4121 for Lakeview Learning Center. Total Line Quantity shows 12, which matches its lines of 8 and 4. The same field and the same search give each order its own total.

SO-4121 shows 12: its own lines of 8 and 4.

Check the result

  1. Run on its own, the saved search returns one row with Sum of Quantity 36.
  2. The Transaction Body Fields list shows Total Line Quantity with ID custbody_so_line_qty_total, Type Integer Number.
  3. SO-4118 shows Total Line Quantity 17, matching 5 + 10 + 2 on its Items subtab.
  4. SO-4121 shows 12, matching its lines of 8 and 4.
  5. A non-administrator role that will use the field sees the value on an order.

Common questions

How do I show the total quantity of all items on a NetSuite sales order?

Build a Transaction saved search that sums Quantity over Sales Order lines, with Main Line, Tax Line, Shipping Line and COGS Line set to false and Internal ID under Available Filters. Then create a transaction body field with Store Value cleared and select that search under Validation & Defaulting > Search. In this example, SO-4118 shows 17 and SO-4121 shows 12.

How do I make a custom field that pulls its value from a saved search?

Create the body field, clear Store Value, and pick the saved search in Validation & Defaulting > Search. Leave Default Value empty. The search has to return one value, so give it a single result column with a Summary Type such as Sum, Count, Minimum, Maximum or Average, and no Group column.

Why doesn't my saved search appear in the custom field's Search dropdown?

Check Available Filters first. The search in this example wasn't offered in the Search list until Internal ID was added there. After that, check that the search is public or shared with your role through its Audience.

What does the Field dropdown under Search do?

It picks which field on the record gets matched through the search. Leave it blank here and NetSuite passes the current order's internal ID into the Internal ID filter, so each order gets its own total. Only set Field when the record should be matched through a different field.

Why must Store Value be unchecked for a saved-search-sourced field?

With Store Value cleared, NetSuite runs the search when the saved order loads instead of saving a number on the transaction. That's what lets SO-4118 show 17 and SO-4121 show 12 from the same search. A stored value wouldn't recalculate when the lines change.

Why doesn't my search-sourced field update while I'm editing the order?

The search reads saved data. Lines you add or change in edit mode aren't counted until you save and reload the order, and a new order has no value until it's saved. If you need a total that updates while editing, that takes a client script.

Can I use a non-stored custom field in a saved search or CSV export?

Don't count on it. The value isn't saved on the transaction, so saved search criteria and columns, list views, CSV exports and printed forms may not have it. If you need the total there, store it with a workflow or script, or calculate it in the search or template itself.

Why is my saved-search custom field blank on invoices?

Applies To > Sale also puts the field on invoices and cash sales. This search only looks at Sales Orders, so it finds no rows for an invoice's internal ID and the field stays blank. Hide the field on those forms, or build a separate search if you want a total there too.