• Shivshi
  • NEWBIE
  • 0 Points
  • Member since 2015
  • Salesforce Developer
  • Boston Scientific

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
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
 
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