You need to sign in to do that
Don't have an account?
Dumber_Texan2
SOQL statement for retrieveing Contact information where Account Name = 'ABC Company'
I've tried this query several ways and I can't get it to work unless I use a number for the Accountid. I would like to use a name instead of a number. According to the documentaiotn on Contact filelds found here (http://na24.salesforce.com/help/pdfs/en/salesforce_field_names_reference.pdf) (page 30), Account Name is an ID instead of a name. Anyway, this is confusing.
Here is the query that works.
Select Id, FirstName, LastName, MailingStreet, MailingCity, MailingState, MailingPostalCode, MailingCountry, MobilePhone, Email, PhotoUrl, CreatedDate, Accountid from Contact where Accountid = 'SOMEID'
Here is how I would like to filter the results.
I would like to retreive all Contacts where the Account Name = "ABC Company'.
Thanks
Here is the query that works.
Select Id, FirstName, LastName, MailingStreet, MailingCity, MailingState, MailingPostalCode, MailingCountry, MobilePhone, Email, PhotoUrl, CreatedDate, Accountid from Contact where Accountid = 'SOMEID'
Here is how I would like to filter the results.
I would like to retreive all Contacts where the Account Name = "ABC Company'.
Thanks
Yes that is correct. AccountId is reference field on Contact so Accountid holds Account record id, so in your case if you want to filter out results on the basis of Account Name you need to write following SOQL
makes sense?
Thanks,
Himanshu
All Answers
Yes that is correct. AccountId is reference field on Contact so Accountid holds Account record id, so in your case if you want to filter out results on the basis of Account Name you need to write following SOQL
makes sense?
Thanks,
Himanshu
Select Id, FirstName, LastName, MailingStreet, MailingCity, MailingState, MailingPostalCode, MailingCountry, MobilePhone, Email, PhotoUrl, CreatedDate, Accountid from Contact where Account.Name='ABC Company'
I hope this will help you. Please let us know if this will help you.
Thanks
Amit Chaudhary
In Standard object you just need to access field by . like Account.Name etc
in custom object object you need to access field by __r.
"__r" is used for retrieving field values from the object's related another object when those objects have relationship via Lookup field.
See links below for detail and samples
In Formula:
http://developer.force.com/cookbook/recipe/displaying-fields-from-a-related-record-on-a-detail-page
In SOQL:
http://www.forcetree.com/2009/07/understanding-relationships-in.html
Please let us know if this will help you
There is no error in documentation, if you will check again that documentation then you will find that Account Name is defiend as Label, so anytime you will see contact detail page instead of showing Account id SFDC shows referred account name for user convenience which makes sense.
see following screenshot
Now talk about the AccountID, Contact and Account share relationship with each other that is why Contact Object contain ID of Account record (foreign key in SQL).
In SFDC whenever you need to get any data from any relational object you query that using relationship name . field name, in your case we did that as Account.Name where Account is relationship name and Name is field of that object.
Makes sense ?