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
Rahul 12Rahul 12 

NSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY

i have created a site in my org.While i am submitting user entered data for a custom field.i am getting error for INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id.
for case object. 

below is my code :
SurveyTaker__c  is my custom object.I have lookup relationship with case for this custom field
SurveyTaker__c st = new SurveyTaker__c();
        st.Contact__c = contactId;
        st.Survey__c = surveyId;
        st.Taken__c = 'false';
        st.Case__c = caseId;
      //  st.Case__c='50055000000xALF';
        st.User__c = userId;
        insert st;  

Thanks in advance
Himanshu ParasharHimanshu Parashar
Hi Rahul,

You don't have access right on Case object that is why this error is coming. You need to give permission for Case object.

Makes sense ?

Thanks,
Himanshu
KaranrajKaranraj
Rahul - Check whether site user profile has write access to the SurveyTaker__c object.
  • Goto Setup->Developer->Sites and then select your site
  • Then click Public Access settings
  • Then click Object settings
  • Then enable Create premission access and save your changes
Now user can able to create record from your site.
 
Rahul 12Rahul 12
Thanks for your reply.Above options I had already done.
Actually in the controller 'With Sharing' condtion was there in class, once i removed that.it's working fine. 
Himanshu ParasharHimanshu Parashar
Hi Rahul,

You can remove With Sharing from your class but that is not best practice to do because code now runs in sys admin context instead of end user, it means any user can update any record.