function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Max PowerMax Power 

Need help with SOQL statement for a custom object with a lookup field

Please forgive my lack of knowledge in this area, but this is my first Salesforce application.  I've created a custom object (called Cred) to store credentials to a 3rd party service.  This custom object has the standard Name field, a password field, and a lookup field that references the User object.  There should only be one entry in the Cred table per user, although there is nothing preventing multiple entries.  I have chosen to implement this way, as this does not require a modification to the User table.
 
I am implementing an Apex web service that will consume a 3rd party web service using the credentials associated with the current Salesforce user.  My problem is that I do not know how to retrieve this record.  I am passing the Apex web service the User.Id of the current user, and I would like to know how to write a SOQL statement to retrieve the Cred entry that references that User account.
 
Any help that you can provide would be greatly appreciated.
 
Thanks in advance,
Max
werewolfwerewolf
First, you definitely should download the Force.com Explorer.  It will allow you to test out your SOQL queries easily.

It sounds like your query will be as simple as

Select [some fields] from Cred__c where User__c=[the user id]
Max PowerMax Power

Thanks so much for the reply.  I suspected that the reference field was an ID, but I couldn't find any documentation that would confirm that.  The SOQL statement that you gave me worked perfectly.  I'll definitely take a look at Force.com Explorer.

-Max