You need to sign in to do that
Don't have an account?
Wrapper Class Dynamic Record ID
I can't figure out how to insert related record ID numbers dynamically. In the sample below they are hard coded and it works as needed, but I need the ID's included in the loop to insert records.
Thank you in advance for you help!
public class DataListingController {
public String CID;
public List<Wrapper> Wrapperlist {get;set;}
public DataListingController(){
CID = ApexPages.currentPage().getParameters().get('id');
//Fetch Referrals
List<Data_Feed__c> dfList = new List<Data_Feed__c>();
Wrapperlist = new List<Wrapper>();
dfList = [SELECT ID, NAME, Rental__r.NAME, Data_Client__r.ID FROM Data_Feed__c WHERE Data_Client__c=:CID ORDER BY Rental__r.NAME];
if(!dfList.isEmpty()){
for(Data_Feed__c df: dfList) {
Wrapper wrap = new Wrapper();
wrap.isSelected = FALSE;
wrap.dfeedObj = df;
Wrapperlist.add(wrap);
}
}
}
/* Insert Apartment functionality based on selected records
*/
public void InsertApartment(){
for(Wrapper wr : Wrapperlist){
if(wr.isSelected = true){
Data_Listing__c dl = new Data_Listing__c();
dl.Data_List__c='a0g55000000S7Cs';
dl.Data_Feed__c='a0m55000001Ihno';
insert dl;
}
}
}
/* Wrapper class with checkbox and Apartment object.
this is also called as inner class
*/
public class Wrapper{
public boolean isSelected {get;set;}
public Data_Feed__c dfeedObj {get;set;}
public Data_List__c dlistObj {get;set;}
}
}
Thank you in advance for you help!
public class DataListingController {
public String CID;
public List<Wrapper> Wrapperlist {get;set;}
public DataListingController(){
CID = ApexPages.currentPage().getParameters().get('id');
//Fetch Referrals
List<Data_Feed__c> dfList = new List<Data_Feed__c>();
Wrapperlist = new List<Wrapper>();
dfList = [SELECT ID, NAME, Rental__r.NAME, Data_Client__r.ID FROM Data_Feed__c WHERE Data_Client__c=:CID ORDER BY Rental__r.NAME];
if(!dfList.isEmpty()){
for(Data_Feed__c df: dfList) {
Wrapper wrap = new Wrapper();
wrap.isSelected = FALSE;
wrap.dfeedObj = df;
Wrapperlist.add(wrap);
}
}
}
/* Insert Apartment functionality based on selected records
*/
public void InsertApartment(){
for(Wrapper wr : Wrapperlist){
if(wr.isSelected = true){
Data_Listing__c dl = new Data_Listing__c();
dl.Data_List__c='a0g55000000S7Cs';
dl.Data_Feed__c='a0m55000001Ihno';
insert dl;
}
}
}
/* Wrapper class with checkbox and Apartment object.
this is also called as inner class
*/
public class Wrapper{
public boolean isSelected {get;set;}
public Data_Feed__c dfeedObj {get;set;}
public Data_List__c dlistObj {get;set;}
}
}
First take a deep breath :) second :-
public void InsertApartment(){
for(Wrapper wr : Wrapperlist){
if(wr.isSelected = true){
Data_Listing__c dl = new Data_Listing__c();
//dl.Data_List__c='a0g55000000S7Cs';
dl.Data_Feed__c= wr.dfeedObj.Id;
insert dl;
}
}
}
Half of the problem will be solved, the other half can be only solved if you just tell me how to get the id of data list like you used soql to fetch
dfList = [SELECT ID, NAME, Rental__r.NAME, Data_Client__r.ID FROM Data_Feed__c WHERE Data_Client__c=:CID ORDER BY Rental__r.NAME];
Is there any soql or anything which is mentioned in the requirement from where i can get data list or it's set of id's or anything?
Thanks
All Answers
Can you tell me the relationship between data feed and data list? How will you be fetching data list object?
Thanks
https://developer.salesforce.com/forums/?id=906F0000000Ae2GIAS
First take a deep breath :) second :-
public void InsertApartment(){
for(Wrapper wr : Wrapperlist){
if(wr.isSelected = true){
Data_Listing__c dl = new Data_Listing__c();
//dl.Data_List__c='a0g55000000S7Cs';
dl.Data_Feed__c= wr.dfeedObj.Id;
insert dl;
}
}
}
Half of the problem will be solved, the other half can be only solved if you just tell me how to get the id of data list like you used soql to fetch
dfList = [SELECT ID, NAME, Rental__r.NAME, Data_Client__r.ID FROM Data_Feed__c WHERE Data_Client__c=:CID ORDER BY Rental__r.NAME];
Is there any soql or anything which is mentioned in the requirement from where i can get data list or it's set of id's or anything?
Thanks
I'm still deciding what I'm going to do about Data_List__c. I'm testing some ideas, but now that you've showed me the path, I think I can figure it out.
Thanks again!!