All Ideas

Idea Details

Post an Idea
330  Points
Open
Idea has been posted. Give it an upvote or downvote.

Support Field-sets in SOQL SELECT clause

Accounts & Contacts

It would be really nice if Salesforce would support Object Fieldsets in SOQL SELECT clauses.  The syntax for such a think might look something like this:

[SELECT 
$Fieldset.MyObjSet, 
Related_Object__r.$FieldSet.RelatedObjSet, //related object
(SELECT $FieldSet.ChildObjSet FROM Child_Objects__r) //inner query
FROM My_Object__c]

This would vastely improve code maintainbiltiy and allow you to define object "models".  For example, I might have a class (Foo) that accepts a List<Contact> records and requires a certain list of fields.  To pass a record into that class the query might look like this:

List<Contact> c =  [SELECT $FieldSet.Foo_Model FROM Contact WHERE ...];
Foo f = new Foo(c);

But somewhere else, I might be querying the Account and want to pass all Contacts into my Foo Class:

List<Account> acc =  [SELECT Id, (SELECT $FieldSet.Foo_Model FROM Contacts) FROM Account WHERE ...];
Foo f = new Foo(acc.Contacts);
 

Sure, you could write a utility class to store to handle all the different ways you might need to query the Contacts, but that requires alot of work, increases techinical overhead and likely causes you code to have to run more SOQL queries.

Merge Idea · Flag

  • Upvotes
  • Downvotes

Ideas

Apps

from AppExchange

Questions

Help us to keep IdeaExchange clean by pointing out overlapping ideas. We'll investigate your suggestion and merge the ideas if it makes sense.



 

 

Thanks for your merge suggestion. We will review it shortly and merge the ideas if applicable.

Salesforce takes abuse situations very seriously. Examples of abuse include but are not limited to posting of offensive language or fraudulent statements. To help us process your request as quickly as possible, please fill out the form below describing the situation. For privacy and security reasons, the final outcome of an abuse case may not be revealed to the person who reported it.


 

Thank you for your feedback. We take abuse seriously and will investigate this issue and take appropriate action.