You need to sign in to do that
Don't have an account?
AAM
Dynamic SOQL - Grab Account Name from Database.QueryString
I have the following QueryString:
String QueryString = 'SELECT Id, Name, AccountId, Account.Name, Phone, Email, OwnerId, Owner.Alias, Active__c, Broker_Number__c, Broker_Number__r.Name, Account.Firm__c FROM Contact WHERE' + QueryActive;
I need to loop through the results and populate a list:
for(sObject o : Database.query(QueryString)) { SearchContact result = new SearchContact((Id)o.get('Id'),(String)o.get('Name'),(Id)o.get('AccountId'),(String)o.get('Account.Name'),(String)o.get('Phone'),(String)o.get('Email'),(Id)o.get('OwnerId'),(String)o.get('Owner.Alias'),(Boolean)o.get('Active__c'),(Id)o.get('Broker_Number__c'),(String)o.get('Broker_Number__r.Name'),(String)o.get('Account.Firm__c')); ContactResults.add(result); }
I keep getting an error that 'Account.Name' is not a valid field for Contact. How am I supposed to retrieve the Account Name, Owner Alias, etc.?
Thanks.
Thanks for the reply. I ended up 'getting' the Objects within the loop and subsequently retrieving the individual fields: