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
clxingclxing 

How to get the 'id' for 'retrieve' method of Force.com WebService

For some Force.com WebService methods, such as retrieve, update, we need to specify the object id. However, the object 'id' value is not visible in UI.

 

How can we get the 'id'value for the target object instance ? Thanks!

Best Answer chosen by Admin (Salesforce Developers) 
werewolfwerewolf

The ID of any object is its primary key.  For any given record, the ID also forms the URL.  For example for this contact:

 

https://na1.salesforce.com/0033000000V2axW

 

The ID is

 

0033000000V2axW

 

You can usually get the ID out of a merge field, like {!Contact.Id}, if you're passing it in via a custom button or Visualforce page.

All Answers

werewolfwerewolf

The ID of any object is its primary key.  For any given record, the ID also forms the URL.  For example for this contact:

 

https://na1.salesforce.com/0033000000V2axW

 

The ID is

 

0033000000V2axW

 

You can usually get the ID out of a merge field, like {!Contact.Id}, if you're passing it in via a custom button or Visualforce page.

This was selected as the best answer
Mark SFMark SF

You can also use SOQL and the query() call to get IDs. From the docs:

 

In general, you use retrieve() when you know in advance the IDs of the records to retrieve. Use query() instead to obtain records when you do not know the IDs or when you want to specify other selection criteria.

 

Client applications can use retrieve() to perform a client-side join. For example, a client application can run a query() to obtain a set of Opportunity records, iterate through the returned opportunity records, obtain the accountId for each opportunity, and then call retrieve() to obtain Account information for those accountIds.