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
Manoprabha PalpandianManoprabha Palpandian 

If it is correct or not any one help me

public void editfunction() {
        system.debug('editfunction inside===>'+editid);
                reg1=[SELECT Id,Name, FirstName__c, LastName__c, Email__c, (SELECT Id,Name, Check_In_Date__c, Check_Out_Date__c, Hotel_Commands__c FROM Hotels__r),
                 (SELECT Id,Name, Arrival__c, Departure__c, Air_Commands__c FROM AirTravels__r)
              FROM Registration1__c where id=:editid];
        hotel.get('id');
        air.get('id');
        
        }


how to get a child record values
ravi soniravi soni
hy ,
try folowing code.
public void editfunction() {
        system.debug('editfunction inside===>'+editid);
              set<Id> HotelIds = new set<Id>();
		      set<Id> AirTravelIds = new set<Id>();
		
		for(Registration1__c reg : [SELECT Id,Name, FirstName__c, LastName__c, Email__c, 
				                   (SELECT Id,Name, Check_In_Date__c, Check_Out_Date__c, Hotel_Commands__c FROM Hotels__r),
                                   (SELECT Id,Name, Arrival__c, Departure__c, Air_Commands__c FROM AirTravels__r)
                                    FROM Registration1__c where id=:editid]){
									for(Hotels__c Hotel : reg.Hotels__r){
									HotelIds.add(Hotel.Id);	
									}
                                    for(AirTravels__r AirTravels : reg.AirTravels__r){
									AirTravelIds.add(AirTravels.Id);	
									}									
									}
        
        }

Above code is just a way to getting child records. In this way I simply add child records value into set. you can set it into map as well or whatever you want.
let me know if it helps you and marking it as best answer.
Thank you
Manoprabha PalpandianManoprabha Palpandian
Invalid type error Hotels__r and AirTravels__r variable does not exist air and hotels
ravi soniravi soni
hy,
try following code.
public void editfunction() {
        system.debug('editfunction inside===>'+editid);
              set<Id> HotelIds = new set<Id>();
		      set<Id> AirTravelIds = new set<Id>();
		
		for(Registration1__c reg : [SELECT Id,Name, FirstName__c, LastName__c, Email__c, 
				                   (SELECT Id,Name, Check_In_Date__c, Check_Out_Date__c, Hotel_Commands__c FROM Hotels__r),
                                   (SELECT Id,Name, Arrival__c, Departure__c, Air_Commands__c FROM AirTravels__r)
                                    FROM Registration1__c where id=:editid]){
									for(Hotel__c Hotel : reg.Hotels__r){
									HotelIds.add(Hotel.Id);	
									}
                                    for(AirTravel__c AirTravels : reg.AirTravels__r){
									AirTravelIds.add(AirTravels.Id);	
									}									
									}
        
        }

let me know if it helps you and marking it as best answer.
Thank you
Manoprabha PalpandianManoprabha Palpandian
This code is not showing an error. when i click the edit button not displaying the values ( reg, air, hotel )
ravi soniravi soni
hy,
try below query in queryEditor and checked  records are comming there.
In Where Condition You replace your editid  with current recordId and then check.  If record is coming then make sure in code editid  is not empty.
SELECT Id,Name, FirstName__c, LastName__c, Email__c, 
				                   (SELECT Id,Name, Check_In_Date__c, Check_Out_Date__c, Hotel_Commands__c FROM Hotels__r),
                                   (SELECT Id,Name, Arrival__c, Departure__c, Air_Commands__c FROM AirTravels__r)
                                    FROM Registration1__c where id=:editid
you have to debug above loop or you can make sure in queryEditor that whatever recordId you are passing through editid, the record is coming or not.
let me know what is your status and if your problam has solved then mark it as best answer.
Thank you
 
Manoprabha PalpandianManoprabha Palpandian
In where condition i am passing the current recordid is id=:reg1.id showing error Unknown error parsing query