You need to sign in to do that
Don't have an account?
roni shore
Unable to fetch records
Hi Guys- I have an custom object "Address__c" related to Account, when passing the account id there I am not getting any records, please suggest
public with sharing class DisplayQueryList{
public List<Address__c> Records {get; set;}
public DisplayQueryList(){
Records = [select Id,Name FROM Address__c WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
system.debug('record-->'+Records);
}
}
public with sharing class DisplayQueryList{
public List<Address__c> Records {get; set;}
public DisplayQueryList(){
Records = [select Id,Name FROM Address__c WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
system.debug('record-->'+Records);
}
}
Please go to your Address Object details, view the field api name of account field there(As its custom field created by you).
Then use that api in where clause.
If you haven’t changed the api during field creation then it must Account__c but recheck and update your code.
All Answers
public List<Address__c> Records {get; set;}
public DisplayQueryList(){
Records = [select Id,Name FROM Address__c WHERE Account__c = :ApexPages.currentPage().getParameters().get('id')];
system.debug('record-->'+Records);
}
}
or
Account__c = :ApexPages.currentPage().getParameters().get('id')]
it doesnt save.
In where clause of SOQL, use the API name of account lookup field instead of id.
If you know the id of Address record then only your existing code will fetch the records from address object.
Please go to your Address Object details, view the field api name of account field there(As its custom field created by you).
Then use that api in where clause.
If you haven’t changed the api during field creation then it must Account__c but recheck and update your code.