function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
mandycmandyc 

Visualforce page not deleting record

Hello,

I have a related list that is a visualforce page. I am trying to use a commandlink to delete records from the related list; however, the code is not working. There is no error message displayed. Any assistance is appreciated!

VF page:
<apex:commandlink value="Del" id="customDelete" onClick="return confirmDelete()">
    <apex:param name="delID" value="{!attorney.ID_1__c}" assignTo="{!SelectedId}"/>
</apex:commandlink>

Class:
public void customDelete()
    {
        New List<Att_IP__c> att = [SELECT Id FROM Att_IP__c WHERE Id = :SelectedId];
        if (att.size() > 0){
            Delete att;
        }
    }


Michael VerhovskiMichael Verhovski
You may need to check that the sObject records you are trying to delete have the deletable property. Try to execute in Develop console something like

delete [SELECT Id FROM Att_IP__c WHERE Id = :SelectedId];


mandycmandyc
Thank you, Michael. I used the developer console to execute the delete statement and the status came back successful. I also ensured that the profile I'm using has delete access to the Att_IP__c object. Any other ideas of what I might try?
mandycmandyc
Does anyone have any other suggestions?
Nikunj DoshiNikunj Doshi
Just ensure that you are initializing SelectedId -> public String SelectedId{get; set;} & also set rerender attribute on command link to "all".

Here`s a detailed blog written by Bob on the topic of passing param http://bobbuzzard.blogspot.sg/2011/07/passing-parameters-to-apex-method-from.html

Hope it helps,
Nikunj Doshi