I have the requirement to show a WARNING POPUP / confirmation box based on a condition. If user edits the opportunity and changes the status to "Closed Won", then clicks on save then depending on whether there are open agreements(Agreement object is child of opp) the user should be shown a warning popup whether they still want to continue. If they click "OK" then the save should happen else it should return to opp or remain on the edit page.

So i found that the save button cannot be overridden. I have tried the following approach.

  1. Write Javascript in the sidebar to show the popup. This method works but its a hack which is not recommended by sf.

Thanks in advance. Any approaches are welcome.

  • An easier way would be to have a confirmation chekbox that needs to be checked when a specific status is set. Else you probably need to go to a custom UI. – Samuel De Rycke Jul 1 '14 at 7:57
up vote 4 down vote accepted

The only supported way to achieve this is through Visualforce, by overriding the entire page. You can't customise the flow of the standard pages, outside of hacking some JavaScript in the sidebar, but even if you go that route it is highly likely to stop working in Summer 15.

One way I've used to achieve similar functionality to that you require is to add a checkbox ('No Open Agreements' in your case) and apply a validation rule that validates the box is checked and if not, throws an error asking them to confirm by checking the box. The downside to this is that some users just tick the box every time they save as they realise this will avoid the error. I usually add a workflow to clear the checkbox upon completed save, so that if the opportunity goes back a stage and then moves to 'Closed/Won' again, the user will have to reconfirm.

As @BobBuzzard said it's only possible using a workaround (please don't call it hack). But if you really go on, don't do it this way: http://bobbuzzard.blogspot.co.uk/2014/06/javascript-in-salesforce-home-page.html This will even stop to be usable in a few days (on summer'14 upgrade!), because you won't be able to save the Text-Areas containing script-tags.

An alternative to be used on a view (not edit) would be Changing the color of a custom button at least you could cover inline-edits.

An approach (working at least in summer'14) to get it even on edit you can see here End of javascript sidebar workarounds?

A big disadvantage of all of these workaround is, that they will probably not work in the mobile salesforce1 app. So if you can live with it, do as @BobBuzzard said.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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