You need to sign in to do that
Don't have an account?
BeautifulDrifter
Trouble Deleting Record from PageBlockTable
Need help here. I have a record within a PageBlockTable and added a button to delete the record. I am doing this on another tab of the same page and it is working fine. For some reason I cannot get this to work.
Pulling the primary data for the table
Here is the VF:
Below is the Apex for the action. You can also see all of the different ways I have tried to delete this record (marked out).
Any help would be much appreciated. Thanks in advance!
Pulling the primary data for the table
Private void setAppDetail(){ AppDetails = [select Id,Name,PSQ_Application__c,Instances__c from PSQ_App_Detail__c where PSQ_Header__c = :Header.Id]; }
Here is the VF:
<apex:pageBlock title="Line Items" id="AppLineItems"> <apex:pageBlockTable value="{!AppDetails}" id="appDet" var="ad"> <apex:column title="Name" value="{!ad.Name}"/> <apex:column title="Socket" value="{!ad.PSQ_Application__c}"/> <apex:column title="Instances" value="{!ad.Instances__c}"/> <apex:column > <apex:commandButton value="Remove App" action="{!removeApp}" id="removeApp" reRender="AppLineItems" > <apex:param name="AppId" value="{!ad.id}" assignTo="{!AppId}"/> </apex:commandButton> </apex:column> </apex:pageBlockTable> </apex:pageBlock>
Below is the Apex for the action. You can also see all of the different ways I have tried to delete this record (marked out).
//public PSQ_App_Detail__c AppId {get; set;} public string AppId {get; set;} public PageReference removeApp() { //PSQ_App_Detail__c deleteApp = AppId; PSQ_App_Detail__c deleteApp = new PSQ_App_Detail__c(Id = AppId); //PSQ_App_Detail__c DeleteApp = [select Id from PSQ_App_Detail__c where Id = :AppId]; //delete AppId; delete DeleteApp; setAppDetail(); return null; }
Any help would be much appreciated. Thanks in advance!
For simplicities sake, I removed the required field and now it is working.
All Answers
" I am doing this on another tab of the same page and it is working fine..." exactly the same or with <apex:commandLink> ?
http://blog.jeffdouglas.com/2010/03/04/passing-parameters-with-a-commandbutton/ (https://th3silverlining.com/2009/06/12/salesforce-bugs-you/)
https://th3silverlining.com/2009/06/12/salesforce-bugs-you/
VF APEX
So is this a bug?
This only difference for your code is the rerender target.
<apex:pageBlock title="Line Items" id="AppLineItems"> ( KO )
<apex:pageBlockTable id="list" value="{!catsList}" var="rc"> ( OK )
The solution is perhaps around that. People have raised suspicions around the target ids of the rerender (the only difference in their code too).
I am interested in the solution of your problem because many people have this issue (including me).
For simplicities sake, I removed the required field and now it is working.
apex:param A parameter for the parent component. The <apex:param> component can only be a child of the following components:
<apex:actionFunction>
<apex:actionSupport>
<apex:commandLink>
<apex:outputLink>
<apex:outputText>
<flow:interview>
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_param.htm
There is not <apex:commandButton> which seems an exception for Salesforce or just a typo here since a recent fix (v39)?
Many people have tried apex:commandButton searching a hack or a work-around and that seems to work with your exact code which can interest other people who want a button on every row of a list (instead of the classic checkboxes with a global action buttton)
Your problem is solved so mark your own answer as the best one.