function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Shatrughna SalunkeShatrughna Salunke 

Invalid IN fields group: PERSONEMAIL OR Custome_Email__C

Hello,

Is there any aletrnative way to achive the  below  sosl and soql error?

For the below code I am getting error

Error : Invalid IN fields group: PERSONEMAIL OR Custome_Email__C

  @AuraEnabled
   public static List<Account>  getData(String entityType)
    {   
       List<account> getDetails=new List<account>();
        List<List<Account>>  accList = [FIND : entityType IN PersonEmail Fields RETURNING Account(id,PersonEmail) limit 1];
        for(List<Account> accountList1 : accList){
            for(Account accountList2 : accountList1){
                if(accountList2.PersonEmail != null )
                {
                    if((accountList2.PersonEmail).equalsIgnoreCase(entityType)  )
                    {
                        getDetails.add(accountList2);
                    }
                }
            }
        }
        return getDetails;
    }
}

Also,getting error for this soql as well 
[Select id,PersonEmail  from Account where PersonEmail =:emailIds]

Error: we canot filter query for PersonEmail

Note: passing email id' from aura method and need to be filter record based on the email id's

 
Best Answer chosen by Shatrughna Salunke
AnudeepAnudeep (Salesforce Developers) 
Ran the SOQL query in my org where I have Person Account enabled and I am not seeing this issue

User-added image

Guess the error you are seeing with your SOSL is expected though because In SOSL you can't search by string value of a Lookup field.

For Example:

Record in object Contact:
Name: David Sidhu

Now there's a related object "LookUpToContact" looking up to parent object Contact.

Try to search "David Sidhu" using SOSL in LookUpToContact Query:

String searchName = 'FIND {David*} IN ALL FIELDS RETURNING LookUptoContact__c(Id, Contact__r.FirstName)';

Returns nothing, just an error (can be verified using workbench).


https://help.salesforce.com/articleView?id=000176100&type=1

All Answers

AnudeepAnudeep (Salesforce Developers) 
Ran the SOQL query in my org where I have Person Account enabled and I am not seeing this issue

User-added image

Guess the error you are seeing with your SOSL is expected though because In SOSL you can't search by string value of a Lookup field.

For Example:

Record in object Contact:
Name: David Sidhu

Now there's a related object "LookUpToContact" looking up to parent object Contact.

Try to search "David Sidhu" using SOSL in LookUpToContact Query:

String searchName = 'FIND {David*} IN ALL FIELDS RETURNING LookUptoContact__c(Id, Contact__r.FirstName)';

Returns nothing, just an error (can be verified using workbench).


https://help.salesforce.com/articleView?id=000176100&type=1
This was selected as the best answer
Shatrughna SalunkeShatrughna Salunke
Thanks-Anudeep

For SOSL problem has been resolved, but stil I'm getting error for soql. is there any setting for this soql?.

Error:

User-added image