0

As per the documentation of salesforce, One can use retrieve() to retrieve one or more records based on the specified IDs.

This is the syntax-based of the above reference document.

sObject[] result = connection.retrieve(string fieldList, string sObjectType, ID ids[]);

What is this connection mean here? I tried the following syntax with no luck

List<String> listIds = new List<String>{'a0H3l00000PE9PMEA1'};
sObject[] result = Database.retrieve('ID, Name', 'Account', listIds);

And received the following error

COMPILE ERROR: Method does not exist or incorrect signature: void retrieve(String, String, List) from the type Database LINE: 2 COLUMN: 29

What am I missing here?

2
  • 4
    The doc example you're looking at is for java and related to the SOAP API. What are you trying to accomplish? If it's just a query, in apex, you can do SOQL queries. Commented Mar 24, 2022 at 18:31
  • Definitely SOQL is the first choice to retrieve records in apex, but I am looking for some other syntax. Commented Mar 24, 2022 at 21:08

1 Answer 1

2

This API unfortunately doesn't exist in Apex. You can call the REST API to get at this data, but it requires a callout. This has been asked for before but closed due to low activity. Unfortunately, you'll have to build your own queries.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .