You need to sign in to do that
Don't have an account?
Deleting Attachments in Visualforce Page
Does anyone know how I can delete an attachment on a VF page by just using a link? I allow my users to upload images to be displayed and I want them to be able to just click a link or small button that allows them to delete the image.
I know I can use the <apex:listViews type="attachment"/> and see all the attachments and get the Edit | Del | View but I just want the delete button. While working with my DE account I was able to use this:
<apex:repeat value="{!Member__c.attachments}" var="attachment" rows="1" first="0"> <a href="/setup/own/deleteredirect.jsp?delID={!attachment.ID}" onclick="confirmation4()">Delete</a> <img src="{!URLFOR($Action.Attachment.Download, attachment.Id)}"/> </apex:repeat>
and I was able to delete with no issues. But with keeping this same code in my Enterprise Production Trial it doesn't seem to work. I highlighted the delete link in the listview to get the URL and created this link:
<a href="/setup/own/deleteredirect.jsp?id={!Member__c.id}&delID={!attachment.ID}">Del.</a>
but I keep getting an error message saying "The attempted delete was invalid for your session. Please confirm your delete." and then there's a delete link right below but I click on it and nothing happens.
Any ideas? I'm stuck.... Thanks!
Add confirmation token parameter and value in url and then try
Hi,
can you expolre more about token parameter.how to give token parameter in url.
ApexPages.currentPage().getParameters().get('_CONFIRMATIONTOKEN')
Actually I am giving hard coded URL from apex and my url is something like that.
PageReference pr = new PageReference ('/ui/portal/DisablePortalUserPage/e?save=1&retURL=%2Fapex/HOC__Contact_Overview%3Frf=No%26id='+string.valueof(cid)+'&id='+string.valueof(cid));
return pr;
can you tell me whether confirmation token take system generated value nad how to give that value in this url. i am eagarly waiting your reply.
add following line in your code
pr.getParameters().put('_CONFIRMATIONTOKEN',ApexPages.currentPage().getParameters().get('_CONFIRMATIONTOKEN'));
HI Nishadh
I tried the approach you told above but the page is sending a e-mail with blank csv file init .can you let me know if you ever encountered the same issue? Thanks in advance.
vivek