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
ShivshiShivshi 

: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY: Access to entity 'SurveyInvitation' denied: Entity is not api accessible

I am implementing salesforce survey, so while creating a survey on the closer of the case,
once surveyinvitation is created then need to update field back on to the case as flag field as true,  I am able to achieve this with process builder but as we don't have any control on the execution of process builder so I want to update the case via apex,

Using trigger on survey invitation object but I am getting an error , please help me on this.
any help will be highly appreciated.
 
Here is my piece of code and we are using handler pattern
Class:

public without sharing class SurveyInvitationTriggerHandler extends TriggerHandler {
    
    
   
    public static list<Case> updCase = new list<Case>();
    /**
    * Called in bulk for after triggers
    * 
    * @param void
    */
    public override void bulkAfter(){
     List<SurveyInvitation> lsSurveyInviation = (List<SurveyInvitation>)trigger.new;
     
     List<Id> casezId = new List<Id>();
     List<Id> workOrderIds = new List<Id>();
     for (SurveyInvitation sI:lsSurveyInviation){
            workOrderIds.add(sI.Work_Order__c);
         
     }

     for(SVMXC__Service_Order__c wo: [ select id,SVMXC__Case__c from SVMXC__Service_Order__c where id in:workOrderIds])
     {
            casezId.add(wo.SVMXC__Case__c);

     }
     
  
    for(case cs : [select id,GSMS_Survey_Sent__c from case where id IN : casezId])
    {
      
      cs.GSMS_Survey_Sent__c=true;
      updCase.add(cs);

    }
    }

    public override void andFinally() {
         if (trigger.isUpdate || trigger.IsAfter) {            
             update updCase;}
    }
}

Error:
INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY: Access to entity 'SurveyInvitation' denied: Entity is not api accessible
 
Lokesh KumarLokesh Kumar
Can you try changing the name SurveyInvitation to SurveyInvitation__c
Khan AnasKhan Anas (Salesforce Developers) 
Hi Rishi,

Greetings to you!

Make sure you are using an API Version greater than or equal to 42.0. Any lower version will fail to compile if it references the SurveyInvitation object. 

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
ShivshiShivshi
@lokesh kumar : thank you for your suggestion and help, but surveyinvitation is not a custom object, its a standard object, I dont think so we can use by appending __c , anyways i tried what you suggested but I am not able to save the class.
SurveyInvitation

 
ShivshiShivshi
Hi Anas,

Thank you for your response, I did cross check but my class version is 46 so I dont think so its occuring because class version and any other suggestion ?

Class version