0

In SOQL, if you don't specify the returned fields and then try to query them, you get an error. Is it the same in SOSL?

List<List<sObject>> values = [FIND 'acme' IN ALL FIELDS RETURNING Account, Opportunity(id, name)];

List <Account> a = values.get(0);
String name = a.get(0).name; // will this line produce an error since we did not specify the name field in the SOSL query

1 Answer 1

3

Yes, you'll get this error whenever you try to access a field you did not retrieve via SOSL/SOQL.

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.