Show a popup window in NetSuite with a Text Input field

NetSuite uses the ExtJS library for a variety of purposes including showing popup windows for alerts and confirmations. We can make use of this to tailor this popup window for our own uses cases which would otherwise couldn’t be met using the standard ‘N/ui/dialog Module’
Note : We are using the ExtJS library which NetSuite used for building their own popup/modal/dialog purpose. If NetSuite decides to upgrade this library or change this to another library, it may break the existing scripts if we use the ExtJS library directly.

Show a popup window in NetSuite with a Text Input field
The following code snippet is for the scenario defined below :
The popup window should have a title and a message. The popup should have an option like a text input field. Upon submission, we should retrieve the value entered by the user in this text field.

To create a popup window in NetSuite using the ExtJS library with a title, message, and a text field, you can use the following code:

// Create a function to show the popup window
function showPopupWindow() {
  // Create a text field
  var textField = new Ext.form.TextField({
    fieldLabel: 'Enter Value',
    allowBlank: false
  });

  // Create the submit button
  var submitButton = new Ext.Button({
    text: 'Submit',
    handler: function() {
      // Retrieve the value entered in the text field
      var enteredValue = textField.getValue();
      
      // Perform any desired actions with the entered value
      console.log('Entered value:', enteredValue);
      
      // Close the popup window
      popupWindow.close();
    }
  });

  // Create the popup window
  var popupWindow = new Ext.Window({
    title: 'Enter the reason',
    layout: 'form',
    items: [textField],
    buttons: [submitButton]
  });

  // Show the popup window
  popupWindow.show();
}

// Call the function to show the popup window
showPopupWindow();

This code will create a popup window with a title, a text field labeled “Enter Value,” and a submit button. Upon clicking the submit button, the value entered in the text field will be retrieved and can be used for further processing.

Leave a comment

Your email address will not be published. Required fields are marked *