1

We have a requirement,where user selects a value on set of records and on save they should get deleted depending on what value they select.

I want to show them a confirmation box like 'Are you sure you want to continue : Ok or Cancel'. And if they select ok,then we delete it.

and I want to even capture the users response in apex code, so that can send mail.

How can i show up this confirmation box for the apex which is called from a trigger & also,how can pass I pass 'Ok' - to the apex code for further processing?

1 Answer 1

2

I do not believe that you will be able to get a 'pop-up' box to be displayed within the trigger. However, what you could do is to override the button that you are using a javascript function that would create a 'pop-up' for the user to 'confirm' their action if they do confirm it to then proceed with the logic of the page, if they cancel their action then to cancel.

If you have jQuery loaded you could do something like the following:

<script type="text/javascript">
    jQuery.noConflict();

    jQuery(document).ready(function() {

        jQuery('.Action').click(function(e) {
            if ( confirm('Are you sure you want to delete this record? Click OK to delete.') ) {
                return true;
            }
            e.preventDefault();
        });
    });
</script>

<!-- somewhere on your page is your button -->
<apex:commandButton action="{!save}" value="Save" styleClass="Action" />

Another option you could do is render a checkbox if the value of the record is one that would require confirmation. This could be done on the selection of the value of the object, or could be done by creating an addError and the page looking for a specific error value before displaying the additional checkbox on the visual page. Then make sure that it is checked prior to doing your actual delete.

2
  • Thanks for the reply,but am not using any visualforce page here..Its a standard object on app and we need to automade one existing process - which is not button drivern and am not sure right now what to do--- Can we call a function/client side scripting on standard picklist field on a value change.?
    – user10727
    Commented Jan 18, 2015 at 16:03
  • Recently Salesforce has started removing unsupported code from HTML Area home page components. At this point there are some options available to you, but they are most likely temporary. Your best bet at developing something long term would be to write your page as a visual force page. If you would like to attempt to try a possible temporary solution look at: salesforce.stackexchange.com/questions/38918/…
    – TC Sutton
    Commented Jan 18, 2015 at 17:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .