Find your content:

Search form

You are here

Why isn't Attachment Delete action recognized when using it with URLFOR

 
Share

I am trying to use the following on a VF page, but I am getting an error when I try to save the VF page.

<apex:outputLink value="{!URLFOR($Action.Attachment.Delete, attachment.Id)}"/>

Error: Field $Action.Attachment.Delete does not exist. Check spelling

The following works in the same page:

<apex:outputLink value="{!URLFOR($Action.Attachment.Download, attachment.Id)}" target="_blank">

Thanks!


Attribution to: PepeFloyd

Possible Suggestion/Solution #1

You're missing a closing quote on the first line. Try finishing it with " target="_blank">


Attribution to: Adam

Possible Suggestion/Solution #2

I don't believe this is possible via an output link. In years past you could use /setup/own/deleteredirect.jsp?delID=<record id> to do this but salesforce added a cross-site request forgery protection that prevents this from working without an additional confirmation.

Likewise the standard delete button actually includes a hidden _CONFIRMATIONTOKEN parameter that appears to be randomly generated for each page view.

So, if you want to do this you'll need to actually use an action component like apex:commandLink or apex:commandButton and call a controller method to perform the delete.


Attribution to: ca_peterson
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/1394

My Block Status

My Block Content