Have you ever overridden the View page of an object but still wanted the Delete functionality? Well, Salesforce has a Javascript function you can utilize to make implementing the original Delete confirmation box extremely simple.
<apex:commandButton value="Delete" action="{!delete}" onclick="return confirmDelete();"/>
When you click a button like above, you will get a popup that looks like:
The reason this popup occurs is because of the onClick event.
onclick="return confirmDelete();"
It utilizes a function that appears in the main.js
file.
function confirmDelete(a){ a||(a=LC.getLabel("Global","are_you_sure")); return Modal.confirm(a) };
This is a file that is provided by Salesforce by default. This will allow you to utilize more built in Salesforce functionality and keep a consistent experience for the end user.
Note: Salesforce can change their Javascript file at any time. While this has not changed in the years I have been working on Salesforce, it is not guaranteed functionality and should be used with caution. Good luck!
Hii jesse,
i’m using above code but i’m not geting the popup msg,
function confirmdelete(a){
a||(a=LC.getLabel(“Global”,”are_you_sure”));
return Model.confirm(a)
};
Hi jesse,
thank you for this. I would like to hide the standard delete confirmation popup and control it from my custom VF and controller. Is that possible? Would you recommend this?
Thanks in support of sharing such a nice thought, post
is good, thats why i have read it entirely
I have overridden delete link on standard visualforce page. It is asking for confirmation via popup when I click on that link. I want to stop generating that popup dialogue box for confirmation. Any way to achieve this.