1

I have a child object - affiliation (in a managed package). It's got M/D relationships to both the Contact and Account standard object in salesforce.

How do I access the contact object's firstname and lastname from within the affiliation object.

For example,

Select pac__contact__c, contact.firstname, contact.lastname
from pac__affiliation__c

This query isn't working and throwing an error at the contact.firstname field. If I remove the contact. fields, it's working fine.

Note pac - is the namespace prefix for the object in the managed pkg.

4
  • It should be contact__r.firstname as contact is a custom field right – Eric Jan 12 '17 at 8:40
  • Eric, Contact is the standard sf object. btw, I tried contact__r. firstname and it didn't work. – JJSHHS Jan 12 '17 at 15:48
  • But Contact on your custom object is not a standard field, you cannot use Contact. it is either Contact__c or Contact__r depending on use – Eric Jan 12 '17 at 15:49
  • Eric, you are correct. It's contact__r with the pac prefix that did it. Thanks for your inputs. I'll mark the answer down as correct. – JJSHHS Jan 12 '17 at 16:27
4

The prefix of your package is "pac" so you have to add this prefix to the fields to be able to request them. You can read the Salesforce documentation about it here.

Also, you can query the look up relationships fields by adding the suffix "__r" to your custom field. As you can see here.

So, this should work:

Select pac__contact__c, pac__contact__r.firstname, pac__contact__r.lastname from pac__affiliation__c
1
  • Martin, this solution worked. Thx for your help. – JJSHHS Jan 12 '17 at 16:27

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.