client script save record delay
# ask-stanley-ai
p
client script save record delay
c
AI generated answer (using internal Slack threads):
Based on the conversations, it seems like you're trying to delay the saveRecord() function in a client script until a dialog box is closed or some other condition is met. In SuiteScript, the N/dialog module is not a modal window like the vanilla JavaScript confirm, so you can't wait for the user's input. Also, SuiteScript does not offer a way to submit the currentRecord. If you must use N/dialog, you have to use JavaScript to do the equivalent of clicking the save button. Here's a code sample from the conversations that attempts to achieve this:
Copy code
javascript
function saveRecord(scriptContext, canSave = false) {
  let canSaveRecord = canSave;

  if (!canSave) {
    canSaveRecord = false;

    const popup = window.open(scriptUrl);
    const timeout = () => {
      window.setTimeout(() => {
        if (!popup.closed) {
          timeout();
        } else {
          saveRecord(scriptContext, true);
        }
      }, 3000);
    };
    timeout();
  } else {
    canSaveRecord = true;
  }
  return canSaveRecord;
}
In this code, the saveRecord function is initially called with
canSave
set to false. It opens a popup and sets a timeout that checks every 3 seconds if the popup is closed. If the popup is still open, it calls the timeout again. If the popup is closed, it calls the saveRecord function again, this time with
canSave
set to true, which allows the record to be saved. Remember, this approach requires you to manually trigger the equivalent of clicking the save button again. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.832375467
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.831419647
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.826951861
Please provide your feedback on this answer.