Display a popup window in NetSuite with a Time Input

Here we use ‘ExtJs’ to show the popup, and this is the one used by NetSuite to display the popup window. So, we can directly utilize this ‘Ext’ library in the scripts. Use the following code to display the popup window to input the time value.

function showPopupWindow() {
  var selectField = Ext.create('Ext.form.Panel', {
    title: 'Event Details',
    width: 400,
    bodyPadding: 10,
    renderTo: Ext.getBody(),
    items: [{
      xtype: 'timefield',
      fieldLabel: 'Event Time',
      name: 'eventTime',
      format: 'H:i',
      increment: 30,
      minValue: '09:00',
      maxValue: '18:00',
      allowBlank: false
    }],
  });

  // Create the save button
  var submitButton = new Ext.Button({
    text: 'Save',
    handler: function() {
      var form = this.up('form').getForm();
      if (form.isValid()) {
        var values = form.getValues();
        // Process and save the form data
      }
    }
  });

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

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

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

Leave a comment

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