fbpx

Free Salesforce Developers Tutorials >

Chapter 7 - SOSL >

How to Access Record in Apex Returned by SOSL

How to Access Record in Apex Returned by SOSL

What You’ll Learn


S2 Labs

What Is Return Type Of SOSL Query?

SOSL query returns a list of list records as in a SOSL query, and records can be of more than one sObject.

How To Access Record In Apex Returned By SOSL

Here is the below example for accessing the record returned by SOSL in Apex:

// Create a variable to store the results of the query.
List<sObject> records = [FIND {searchTerm} RETURNING FROM Account(Name) IN ALL FIELDS];

// Loop through the records and access the fields that you need.
for (SObject record : records) {
  System.debug(record.get('Name'));
}
salesforce-developer

Download Study Material

Get access to exclusive study material for Salesforce Certification and ace your exams!

Download Now

Our Salesforce Certification Courses

Hey there! Glad you made it through our Salesforce Developer Training for beginners . But wait! We've got some high-in-demand Salesforce courses for you to take your Salesforce skills to the next level, making you a desired professional in the Salesforce job market.

Post a Comment

Your email address will not be published. Required fields are marked *