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
satish waghsatish wagh 

SOQL Query On Junction Object Not Return Data For Site Guest User

I have created a junction object called 'Test1__c' between Opportunity and Contact, soql query on Test1__c object return nothing and got below error.
"System.QueryException: List has no rows for assignment to SObject".
I have given read permissions to the Opportunity, Contact and Test1__C object on the Profile of the site guest user but the problem still persists. Also mark apex class as a 'Without Sharing'.
On sharing setting module please the see the below setting:
User-added imageAlso,Please see below piece of code:
public without sharing class EmploymentIntegration {

public static string generateRequestJSON(String contactId,String lob,string uan,String officialEmail)
    {  
        
        system.debug('contactId'+contactId);//got value for contactId here successfully
        system.debug('lob'+lob);
        system.debug('uan'+uan);
        system.debug('officialEmail'+officialEmail);
        try
        {
            
            Employment_Details__c emp = [select id ,Employer_CIN__c,name,Applicant__r.name ,Applicant__r.MobilePhone,
                                         Applicant__r.Email,Applicant__r.Official_email_ID__c,
                                         Applicant__r.Applicant_Type__c,Company_Master__r.name,Applicant__c 
                                         from Employment_Details__c 
                                         where Is_Current_Employer__c = true and Applicant__r.Applicant_Type__c = 'Primary Applicant' 
                                         and Applicant__c =:contactId LIMIT 1];
            
        }
        catch(Kotak_CustomException ex){
           
        }  
        
    }
}

If removing Applicant__c=:contactId from WHERE clause then it returns data.
WHERE Is_Current_Employer__c = true AND Applicant__r.Applicant_Type__c = 'Primary Applicant' AND Applicant__c =:contactId LIMIT 1

 I did all the possible ways that need to resolve this problem but no use. Please help me to resolve this issue, I would be so thankful!