You need to sign in to do that
Don't have an account?

Delete Confirmation Message Box
Using VF, I have modified some of my related lists to display additional columns of information (from objects not available in the "stock" lists). Beyond that I want these re-created lists to look and feel the same as the "stock" ones. And they do, with just one exception: there is no confirmation that pops up when the Del link is clicked.
Code:
<apex:outputLink value="/setup/own/deleteredirect.jsp">Del <apex:param name="Id" value="{!priority.ID_3__c}"/> <apex:param name="delID" value="{!priority.ID_1__c}"/> <apex:param name="retURL" value="/{!priority.ID_3__c}"/> </apex:outputLink>
As you can see the link has the same URL as the stock link and the params provide the needed information from the controller extension. What do I need to do to get the confirmation pop-up? The users are paranoid about accidentally deleting something.
Thanks,
Mauricio
You can add such a question as onsubmit for the form or onclick on the output link, i believe. I've not tried this yet.
I've got the onClick in there and it does bring up the confirmation box but do I have a way of getting the required query string parameters in there? I've tried adding '?Id={!priority.ID_3__c}' at the end of the URL or just using {0} and neither manages to get the data in there. Any ideas?
Thanks,
Mauricio
Here's what worked:
I kept digging around the page with view source and noticed that some of the delete links called confirmDelete() instead of having the inline snippet from above. Not sure why it's done two different ways but nevertheless, this works.
Mauricio
Thanks mworld for sharing the code.....and here is the code for javascript function confirmDelete(), incase other readers may want to utilize.
<script language="javascript">
function confirmDelete(){
if(confirm('Are you sure you want to delete?'))
return true;
return false;
}
</script>
Cheers!
For Command Links or Buttons, it is a lot simpler than that:
<apex:commandLink value="Remove" onclick="return confirm('Are you sure?')" action="{!removeMember}" >
<apex:param name="removeMemberId" value="{!m.Id}" assignTo="{!selectedMemberId}" />
</apex:commandLink>
If the onclick call to confirm() returns false, the action is not called. That's all you need.
Pinkelk, thank you! There are a number of untidy solutions which have been posted in various places, but this is perfect. I'm not sure I understand why it works, as I would have expected onclick to be independent of the action. Anyway, this helped me out, so thanks again.
@pinkelk
This works perfect. Thank you.
Bharath