0

I don't know how to reference the value of the Job_Matching_Title__r.Salary_Range_Avg__c field from this query:

List<Position__c> Positions = [SELECT Name, Department__c,  Job_Matching_Title__r.Name, Job_Matching_Title__r.Salary_Range_Avg__c FROM Position__c WHERE Department__c = :StringDepartmentID];

for (Position__c p :Positions){
    system.debug('Average Salary: ' + Job_Matching_Title__r.Salary_Range_Avg__c );
}

The error message is:

"Variable does not exist"

I'm expecting to see a numeric value. I can run the query in the Schema Explorer so the query seems fine, I just don't know how to reference that related record field value.

Thanks,

Kevin

4

You forgot the Position p object in your loop.

Try :

List<Position__c> Positions = [SELECT Name, Department__c,  Job_Matching_Title__r.Name, Job_Matching_Title__r.Salary_Range_Avg__c FROM Position__c WHERE Department__c = :StringDepartmentID];

for (Position__c p :Positions){
    system.debug('Average Salary: ' + p.Job_Matching_Title__r.Salary_Range_Avg__c );
}
1
  • You're welcome.
    – SF_user
    Sep 5 '14 at 14:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.