You need to sign in to do that
Don't have an account?
Sukhdeep Singh
I am using delete for attachments, But Its not working
<td align="center" style="font-weight: bold;color:Red;"><a href="{!URLFOR($Action.Attachment.delete, a.Id)}">Delete</a></td>
I am getting Error: Field $Action.Attachment.delete does not exist. Check spelling
Please suggest, How can I delete
I am getting Error: Field $Action.Attachment.delete does not exist. Check spelling
Please suggest, How can I delete
@Sukhdeep Singh:
Hi,
There is no Action available for attachment object except download, the valid values were in the below link:
http://www.salesforce.com/docs/developer/pages/Content/pages_variables_global_action_valid_values.htm
Looks like you were trying to do that from a Visualforce page, so you can use a method from controller to delete attachment which can be called from the td tag:
<td .... onclick="deleteAttachment({!a.id});" />
or you can call onclick from anchor tag its self
<apex:actionFunction name="deleteAttachment" action="your controller method">
<apex:param name="attachmentIdParam" value="" assignTo="{!yourvariablefromController}" />
</apex:actionFunction>
Controller:
public pageReference yourControllerMethod(){
try{
Attachment att=new Attachment(id=yourvariablefromController);
delete att;}catch(Exception e){
//handle your error
}
return null;
}
Hope this helps:
Thanks,
Balaji
All Answers
@Sukhdeep Singh:
Hi,
There is no Action available for attachment object except download, the valid values were in the below link:
http://www.salesforce.com/docs/developer/pages/Content/pages_variables_global_action_valid_values.htm
Looks like you were trying to do that from a Visualforce page, so you can use a method from controller to delete attachment which can be called from the td tag:
<td .... onclick="deleteAttachment({!a.id});" />
or you can call onclick from anchor tag its self
<apex:actionFunction name="deleteAttachment" action="your controller method">
<apex:param name="attachmentIdParam" value="" assignTo="{!yourvariablefromController}" />
</apex:actionFunction>
Controller:
public pageReference yourControllerMethod(){
try{
Attachment att=new Attachment(id=yourvariablefromController);
delete att;}catch(Exception e){
//handle your error
}
return null;
}
Hope this helps:
Thanks,
Balaji
Your idea worked for me i used below code
<td align="center" style="font-weight: bold;color:Red;">
<apex:commandLink value="Delete" action="{!deleteAttachment}" >
<apex:param name="var" value="{!a.id}" assignTo="{!var}"/>
</apex:commandLink>
</td>