ANS-1102 · CUSTOM FIELDS, RECORDS & FORMS

How to Automatically Generate a UPC Check Digit in NetSuite Workflows?

Automate the generation of the 12th check digit for UPC codes on NetSuite item records via custom workflow formulas.

Short answer

The solution involves creating a NetSuite workflow that triggers on item creation or update. It uses a custom formula to calculate the UPC check digit based on the existing 11 digits or a sequence, then appends this digit to form the complete 12-digit UPC. This ensures accurate and automated UPC generation.

Scenario

NetSuite users often need to automatically generate complete UPC codes, including the 12th check digit, for new or updated item records. This requirement can manifest in two primary ways: either appending the check digit to an existing 11-digit UPC, or generating a full 12-digit UPC based on a predefined sequence.

Solution

This solution outlines how to implement a NetSuite workflow to automatically generate the UPC check digit. The approach can be adapted for two common scenarios:

  1. Appending the 12th Digit:

    A workflow is triggered on After Submit if the UPC Code field contains 11 digits. This scenario assumes the user enters the first 11 digits.

  2. Generating a Full UPC from a Sequence:

    For new item creation, a workflow automatically generates a unique UPC based on a starting UPC range number. The starting number is saved as a Workflow variable and incremented by the Item internal ID.

    In both scenarios, the 11-digit UPC number (from scenario 1) or the 12-digit UPC number (from scenario 2) is used in the following formula to calculate the check digit:

MOD(SUBSTR({custworkflow_wf_next_upc_number}, 2, 1)+SUBSTR({custworkflow_wf_next_upc_number}, 4, 1)+SUBSTR({custworkflow_wf_next_upc_number}, 6, 1)+SUBSTR({custworkflow_wf_next_upc_number}, 8, 1)+SUBSTR({custworkflow_wf_next_upc_number}, 10, 1)+(SUBSTR({custworkflow_wf_next_upc_number}, 1, 1)+SUBSTR({custworkflow_wf_next_upc_number}, 3, 1)+SUBSTR({custworkflow_wf_next_upc_number}, 5, 1)+SUBSTR({custworkflow_wf_next_upc_number}, 7, 1)+SUBSTR({custworkflow_wf_next_upc_number}, 9, 1)+SUBSTR({custworkflow_wf_next_upc_number}, 11, 1)) * 3,10)

The calculated digit, which is stored in a variable (e.g., UPC building), is then appended to the existing UPC number and saved to the UPC Code field using this formula:

UPC CodeÊSE WHEN {custitem_upc_building} '10' THEN CONCAT({custworkflow_wf_next_upc_number},'0') ELSE CONCAT({custworkflow_wf_next_upc_number},{custitem_upc_building}) END

A similar formula structure could be adapted for EAN13 codes.

Expert NetSuite Support

Need help with this NetSuite issue?

Custom Fields, Records & Forms consulting and configuration support

Talk to a consultant