Has anyone tried that before? On a Client record, ...
# suitescript
l
Has anyone tried that before? On a Client record, I'm displaying suitelet popup on saveRecord() so the user can make additional decissions based on the outcome of duplicate search. What I want to do is to wait until the popup is closed, then save a record. I thought I'll try to return false on the first execution of saveRecord(), then manually call it once popup is closed. That doesn't save the record unfortunately, function runs in the background, but nothing happens eventually. Here's the code I have:
Copy code
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;
}
b
you will have to do the equivalent of clicking the submit button again