When running a SOSL query as the Site Guest User in an Experience Site, I am unable to retrieve any results if I return more than one object at a time while the search query is 'gmail.com'
As an example, the following does not return any records:
String emailId = '[email protected]'
String emailDomain = 'gmail.com'
List<List<sObject>> testQuery = [FIND :emailDomain IN ALL FIELDS RETURNING Contact (Name WHERE (Email = :emailId OR SecondaryEmail__c = :emailId)), Lead (Id, Email, Name, Account__c WHERE Email = :emailId)];
While, this returns a single Contact record, as expected:
String emailId = '[email protected]'
String emailDomain = 'gmail.com'
List<List<sObject>> testQuery = [FIND :emailDomain IN ALL FIELDS RETURNING Contact (Name WHERE (Email = :emailId OR SecondaryEmail__c = :emailId))];
- If I run the first query as any non Site Guest User it returns results across both objects.
- If I alter emailDomain to virtually any non 'gmail.com' value it works as expected.
- The objects I query largely do not seem to matter(the final full query in the environment includes User, Contact, Account, and Lead)
I have also verified in multiple ways that the Site Guest User does indeed have access to the Objects and Fields in question (queried via SOQL, verified in the profile UI & sharing settings, can query the records if the domain is not 'gmail.com')