Alright in a saveRecord function on a client scrip...
# suitescript
n
Alright in a saveRecord function on a client script, I have some logic to check for duplicate records and warn the user about continuing. Whatever that's all fine. The problem is I am using dialog.confirm() to prompt the user to say "yeah its ok keep going anyway", but it appears that netsuite just returns the promise object and then continues on with the rest of the save record function, then just ignores the user input. So when i prompt the user and get the popup, regardless of what they click, it always returns false. Does anyone know how i can get netsuite to 'wait' for user input to continue. code snippet
Copy code
dialog
            .confirm({
              title: 'No End Date',
              message: `Current Brokerage Contract ${isDuplicate.existingContract.name} has no end date. 
                      If a new contract is created, current contract end date will be populated one day before start date of new contract. 
                      Would you like to continue?`
            })
            .then((result) => {
              if (result) {
                currentRecord.setValue({
                  fieldId: contractFields.fields.closePreviousContract,
                  value: isDuplicate.existingContract.id
                });
                return true;
              }

              return false;
            });
b
you will want to use confirm instead, its synchronous
n
Yeah i was afraid of that. I was trying to avoid it for no other reason than my own pride. Thanks @battk
b
if you wanted to use the asynchronous N/dialog, you have to return false, and then do the equivalent of clicking the save button again in the callback of your promises
which is honestly an absurd amount of work considering how easy confirm is
n
Lol that's what i did
Copy code
dialog
  .confirm({
    title: 'No End Date',
    message: `Current Brokerage Contract ${isDuplicate.existingContract.name} has no end date.
            If a new contract is created, current contract end date will be populated one day before start date of new contract.
            Would you like to continue?`
  })
  .then((result) => {
    if (result) {
      currentRecord.setValue({
        fieldId: contractFields.fields.closePreviousContract,
        value: isDuplicate.existingContract.id
      });
      document.getElementById('main_form').submit();
    }