I am getting this error: System.IndexOutOfRangeException: Cannot find column Contact__r.Contact_Country__c.
How can we resolve this?
1 件の回答
Hey @Rajeshwari Jain, the error typically occurs because the referenced field Contact__r.Contact_Country__c is either not present in the query result or is incorrectly referenced.
To fix this:
- Make Sure to Include the Field in the Query: Verify that Contact__r.Contact_Country__c is selected in your SOQL query:
- SELECT Id, Contact__r.Contact_Country__c FROM ParentObject__c WHERE ...
- Check for Null Values: Sometimes, Contact__r might be null if there’s no related Contact. Use a null check before accessing it.
- Ensure that Contact_Country__c is accessible to the user by checking field-level security or permissions.
Thanks!
- Make Sure to Include the Field in the Query: Verify that Contact__r.Contact_Country__c is selected in your SOQL query: