mlc-logo 30 years

NetSuite ERP: Develop a Custom Script to Get Input and Print on the Label

This article demonstrates scripting in NetSuite to add functionality which does not exist out-of-the-box. Provided below is a step-by-step guide to create functional scripts which add a system prompt to capture user input and include that user input on the resulting label. By leveraging NetSuite’s powerful customization capabilities in a like manner, businesses can streamline their labeling processes and improve overall productivity.

How We Help You Make the Most of Your Technology

Technology products tend to be complex, and finding technical support or a specific solution to a problem can take days of internet searching and forum browsing. At MLC and Associates, we pride ourselves on having the experience and skillset needed to beat even the vendors themselves and get you answers NOW.

We specialize in guiding companies through every stage of digital transformations, including the nitty gritty configuration details. Contact us to learn how we can help your business with digital transformation services that will drive productivity.

The Use Case for Adding User Input to a Label Before Printing

The example in this article solves this use case scenario: a business needs to print an Item Label with a user-defined quantity value. The tricky part is that the user-defined quantity is dynamic and must be entered at the time of label printing.

One option is to add a custom field to the Item Entry Form such that the quantity can be defined per item and stored on the item. However, this doesn’t fully satisfy the requirement because 1) the business does not want to give the group(s) responsible for printing Item Labels the permission to modify Item records, and 2) the quantity should not be stored.

The preferred option to satisfy this use case scenario to add a custom button to the Item record which will generate a prompt to collect user input (e.g. the Quantity) and then print the preferred Item Label Template which includes the custom quantity which was entered in the prompt.

Table of Contents

Step #1: Download the Script Files

  1. For your convenience, the script files may be downloaded from GitHub. Navigate to the Develop a Custom Script to Get Input and Print on the Label repository on GitHub.
  2. Download the 3 JavaScript files to be imported into NetSuite.
    1. addLblButtonUserEvent.js
    2. exportLblClientScript.js
    3. exportLblSuitelet.js

Step #2: Create the Suitelet in NetSuite

  1. Navigate to Customization > Scripting > Scripts > New.
  2. Click the + (New) button.
  3. In the File Name field, enter the file name exactly as it appears on the downloaded file. E.g. “exportLblSuitelet.js”.
  4. Choose a Folder in which to store the file (the default “SuiteScripts” will work).
  5. Click the Choose File button and choose the “.js” file for the Suitelet.
  6. Click the Save button.
  7. Now, click the Create Script Record button.
  8. In the Name field, enter “Export Lbl Suitelet”.
  9. In the ID field, enter “_export_lbl_suitelet”.
  10. On the Save button, click the dropdown arrow and choose “Save and Deploy”.
  11. In the Title field, enter “Export Lbl Suitelet”.
  12. In the ID field, enter “_export_lbl_suitelet”.
  13. In the Audience section, check the “Select All” checkbox for Internal Roles to deploy this script for all roles.
  14. Change the Status from “Testing” to “Released”.
  15. Click the Save button and take note of the External URL (this will be used later).

Step #3: Create the User Event Script in NetSuite

  1. Navigate to Customization > Scripting > Scripts > New.
  2. Click the + (New) button.
  3. In the File Name field, enter the file name exactly as it appears on the downloaded file. E.g. “addLblButtonUserEvent.js”.
  4. Choose a Folder in which to store the file (the default “SuiteScripts” will work).
  5. Click the Choose File button and choose the “.js” file for the User Event script.
  6. Click the Save button.
  7. Now, click the Create Script Record button.
  8. In the Name field, enter “Add Lbl Button User Event”.
  9. In the ID field, enter “_add_lbl_button_ue”.
  10. On the Save button, click the dropdown arrow and choose “Save and Deploy”.
  11. In the Applies To field, select a record for which this deployment should apply to.
    1. For this demonstration, the script is only being deployed to “Inventory Part” records.
    2. Other records which the script may be deployed to include “Lot Numbered Inventory Items” and “Non-Inventory Parts”.
  12. In the ID field, enter “_add_lbl_btn_invpart”.
  13. In the Audience section, check the “Select All” checkbox for Internal Roles to deploy this script for all roles.
  14. Change the Status from “Testing” to “Released”.
  15. Click the Save button.
  16. Repeat steps 11 through 15 for additional deployments of the Add Lbl Button User Event script.

Step #4: Create the Client Script in NetSuite

  1. Navigate to Customization > Scripting > Scripts > New.
  2. Click the + (New) button.
  3. In the File Name field, enter the file name exactly as it appears on the downloaded file. E.g. “exportLblClientScript.js”.
  4. Choose a Folder in which to store the file (the default “SuiteScripts” will work).
  5. Click the Choose File button and choose the “.js” file for the Client Event script.
  6. Click the Save button.
  7. Now, click the Create Script Record button.
  8. In the Name field, enter “Export Lbl Client Script”.
  9. In the ID field, enter “_export_lbl_cs”.
  10. Click the Save button. There is no deployment necessary on this script.

Step #5: Design the Label Template

  1. If no Item Label template exists, create one. Otherwise navigate to the existing Item Label template to update it.
  2. Add a section in the Item Label template with this code: Quantity: ${customData.quantity}
  3. Click the Change ID button and take note of the Old ID field (this will be added to the Suitelet later). Click Cancel to avoid making any changes to the ID.
  4. Click the Save button.

Step #6: Update the Client Script and Suitelet

  1. Navigate to Documents > Files > SuiteScripts.
  2. Update the Client Script.
    1. Find the “exportLblClientScript.js” file and click the Edit button.
    2. In the Media Item field, click the Edit button.
    3. On line 15 where the variable suiteletUrl variable is declared, replace the “INSERT URL” text with the External URL of the Suitelet which was noted at the end of Step #2 above.
    4. Click the Save button on the form to close it and then click the Save button again on the first form.
  3. Update the Suitelet.
    1. Find the “exportLblSuitelet.js” file and click the Edit button.
    2. In the Media Item field, click the Edit button.
    3. On line 22, replace the ID within the single quotes (KEEP THE SINGLE QUOTES) ID of the Item Label template which was noted at the end of Step #5 above.
    4. Click the Save button on the form to close it and then click the Save button again on the first form.

Step #7: Validate that the Button Appears and the Prompt for User Input Appears

  1. Navigate to an Item Record for which Item Type was selected during the creation of deployments in Step #3.
  2. Verify that you can see the Print Qty Lbl button.
  3. Click the Print Qty Lbl button and verify that a prompt appears prompting you to enter a quantity.
  4. Enter a value in the quantity prompt and then click OK and verify that the label generates correctly with the value included.

Click here to go back to the table of contents.