Explore Courses Blog Tutorials Interview Questions
0 votes
in Salesforce by (11.9k points)

I'm trying to build a query builder, where the sObject result can contain an indeterminate number of fields. I'm using the result to build a dynamic table, but I can't figure out a way to read the sObject for a list of fields that were in the query.

I know how to get a list of ALL fields using the getDescribe information, but the query might not contain all of those fields.

Is there a way to do this?

1 Answer

0 votes
by (32.1k points)
edited by

Looks like you're building the query up as a string since it's dynamic, so couldn't you just loop through the fields in the description information, and then use .contains() on the query string to see if it was requested? Not crazy elegant, but seems like the simplest solution here.

Taking this further, maybe you have the list of fields selected in a list of strings or similar, and you could just use that list?

Want to learn about Salesforce in depth? Enroll in this Salesforce course provided by Intellipaat!

Browse Categories