1

I have a custom button on the Account object that, when clicked, renders a VF page in a new window. I'm wondering if it is possible to have a pop-up before executing the vf page to have the user confirm what they are about to do, and they can either hit cancel or continue.

1

If you set the button up to have "Behavior" of "Execute JavaScript" and "Content Source" of "OnClick JavaScript" then you can use a JavaScript confirm to OK or Cancel the navigation to the new window.

  • Is this the only way? Somebody I'm working with told me to avoid using the Execute JavaScript because it rarely works well, and the functionality I want would ideally display a visual force page upon clicking. I'm hoping for an option that involves that. Suggestions? – Natalie Spatharakis Oct 24 '16 at 13:31
  • @NatalieSpatharakis In my experience Execute JavaScript always works. But sure you can do something more complicated if you want to. – Keith C Oct 24 '16 at 13:37
  • The following JavaScript should be fairly self-explanatory in what I'm trying to accomplish. Any suggestions as to why it isn't updating what I'd like? confirm("Are you sure you want to make a new Badge? This will expire the existing one."); {!Account.card_version__c} + 1 – Natalie Spatharakis Oct 24 '16 at 13:38
  • @NatalieSpatharakis I don't understand what {!Account.card_version__c} + 1 is meant to do in JavaScript. Suggest you post a new question with all the relevant information in it. – Keith C Oct 24 '16 at 13:41
  • Again, the syntax may be wrong but the intent is pretty straight-forward. It's an integer, increment it by one. Apologies if that was not immediately obvious, I don't know what the proper syntax is but I thought that would represent my best guess. – Natalie Spatharakis Oct 24 '16 at 15:02
0

You can add this in the button code--->

var conf = confirm("Are you sure you want to this operation?"); if(conf == true){ //write your code }

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.