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 = 'testemail@gmail.com'
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 = 'testemail@gmail.com'
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')

New contributor
nuadaria is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
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? – Kris Goncalves Jun 11 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 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) – Kris Goncalves 10 hours ago

Your Answer

nuadaria is a new contributor. Be nice, and check out our Code of Conduct.

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

Browse other questions tagged or ask your own question.