You need to sign in to do that
Don't have an account?
coolkrish
Passing Selected Record Id in a related list on click of button
Hi,
I am trying to pass a selected record in a related list to controller from VFP.
I am getting error: Unknown constructor 'RR_Multi_Emp_Trainings.RR_Multi_Emp_Trainings(ApexPages.StandardController controller)'
apex class:
public class RR_Multi_Emp_Trainings {
public ApexPages.StandardSetController setCon;
public RR_Multi_Emp_Trainings(ApexPages.StandardSetController controller) {
setCon = controller;
}
public integer getMySelectedSize() {
return setCon.getSelected().size();
}
public integer getMyRecordsSize() {
return setCon.getRecords().size();
}
}
VFP:
<apex:page standardController="RREmployee_Trainings__c" extensions="RR_Multi_Emp_Trainings" showHeader="false" sidebar="false" setup="false">
</apex:page>
Please help.
Thanks,
Krishna.
I am trying to pass a selected record in a related list to controller from VFP.
I am getting error: Unknown constructor 'RR_Multi_Emp_Trainings.RR_Multi_Emp_Trainings(ApexPages.StandardController controller)'
apex class:
public class RR_Multi_Emp_Trainings {
public ApexPages.StandardSetController setCon;
public RR_Multi_Emp_Trainings(ApexPages.StandardSetController controller) {
setCon = controller;
}
public integer getMySelectedSize() {
return setCon.getSelected().size();
}
public integer getMyRecordsSize() {
return setCon.getRecords().size();
}
}
VFP:
<apex:page standardController="RREmployee_Trainings__c" extensions="RR_Multi_Emp_Trainings" showHeader="false" sidebar="false" setup="false">
</apex:page>
Please help.
Thanks,
Krishna.
I think since you are only passing a single Sobject Record Id, hence, you should use the StandardController instead. Update the constructor code to as follows and then query the related records to display on your related list using a Soql Query. Morevoer, I see your Apex Controller does not have the with sharing keyword which should be included unless there is a specific reason.
Thanks for your reply.
I have a button on the related list and I need to pass the record Id of the selected record on click of that button to my extension controller.
This very Id is not getting passed.
Here is the code of my extension controller:
public with sharing class RR_Multi_Emp_Trainings {
public ApexPages.StandardController setCon{get;set;}
public RREmployee_Trainings__c etObj {get;set;}
public RR_Multi_Emp_Trainings(ApexPages.StandardController controller) {
this.setCon = controller;
this.etObj = (RREmployee_Trainings__c)setCon.getRecord();
Id aId = etObj.Id;
System.debug('etObj:'+ etObj);
What is wrong in this....I am not getting value into etObj.
Expectation is to get the record selected in the related list into this variable on click of a button.
Moreover, you will need to use any of the following techniques to make the selected Id available to your controller extension.