0

I have a JavaScript button that I'm having an issue with. When trying to use the cancel button below, when I click cancel it still goes to the redirected URL when that should only occur on Ok.

enter image description here

This is my code:

    else{ Modal.confirm 
         && Modal.confirm('\n\nDo you want Continue?\n') 
         navigateToUrl('{!URLFOR( $Action.Opportunity.Submit, Opportunity.Id         )}'); 

}
1

There's no "if" statement here, so it doesn't branch. You need another if statement in there somewhere. Depending on the surrounding code, either of the following forms may be appropriate:

else if(Modal.confirm && Modal.confirm('Do you want to continue?')) {
    navigateToUrl(...);
}

... or ...

else {
    if(Modal.confirm && Modal.confirm('Do you want to continue?')) {
        navigateToUrl(...);
    }
}

I generally prefer the first form, as it's slightly more compact, but if there's future else options in the code, then the second form is probably going to be better.

0

fixed the issue with this:

else { 
if(r == true){ 
   navigateToUrl('{!URLFOR( $Action.Opportunity.Submit, Opportunity.Id )}'); 
} else { 

} 
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.