Delete Confirmation Popup

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){
	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!

4 Responses to “Delete Confirmation Popup”

  1. sreenivasulu
    January 22, 2014 at 2:12 am #

    Hii jesse,

    i’m using above code but i’m not geting the popup msg,

    function confirmdelete(a){
    return Model.confirm(a)

  2. Ilaria
    February 10, 2015 at 6:57 am #

    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?

  3. May 9, 2015 at 2:44 am #

    Thanks in support of sharing such a nice thought, post
    is good, thats why i have read it entirely

  4. Harikrishna
    July 26, 2016 at 11:35 pm #

    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.

Leave a Comment