Tu PHAN
Tu PHAN

Reputation: 59

Browser.msgBox with CANCEL

We have this code below is working fine, except but when you hit cancel, the script still run ( email() and copy(), in stead of cancel Do you see what is my wrong ?

Thank

function combine() 

{ var confirm_yc = Browser.msgBox('AreYouSure', 'Confirm ?', Browser.Buttons.OK_CANCEL);

  if (confirm_yc == 'ok')
    SendEmail();
  copy();   

}

Upvotes: 1

Views: 282

Answers (1)

Tanaike
Tanaike

Reputation: 201473

At your following script,

function combine() {
  var confirm_yc = Browser.msgBox('AreYouSure', 'Confirm ?', Browser.Buttons.OK_CANCEL);
  if (confirm_yc == 'ok')
    SendEmail();
  copy();
}

The if statement of if (confirm_yc == 'ok') doesn't use {}. In this case, when confirm_yc == 'ok' is true, SendEmail() and copy() are run. On the other hand, when confirm_yc == 'ok' is false, SendEmail() is not run. But copy() is run. I thought that this might be the reason of your issue. So in your script, how about the following modification?

function combine() {
  var confirm_yc = Browser.msgBox('AreYouSure', 'Confirm ?', Browser.Buttons.OK_CANCEL);
  if (confirm_yc == 'ok') {
    SendEmail();
    copy();
  }
}

Reference:

Upvotes: 1

Related Questions