0

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')

3
  • Welcome! There's been quite a few security updates to Guest Users so I suspect it might be related - are there any guest sharing rules? Jun 11, 2021 at 14:21
  • I thought that might be the issue, but I have verified that the Guest User has access to the records in question via querying them directly with SOQL, reviewing sharing/object security/FLS. Also, I wouldn't expect one of these queries to work if this was access related, right?
    – nuadaria
    Jun 11, 2021 at 14:56
  • How many contacts and leads do you have? SOSL can behave differently when querying against one object versus multiple (documentation and previous question) Jun 16, 2021 at 3:39

0

You must log in to answer this question.

Browse other questions tagged .