Sometimes the Shifts that are deleted in Salesforce still show up on the V4S Kiosk application. That is because the shift is deleted by a Salesforce user who does not have access to the V4S Mobile objects in Salesforce.


The Shifts deleted in Salesforce and in the V4S Kiosk application, only if the Salesforce user that deleted the Shifts has access to the V4S Mobile objects in Salesforce.


Things to be taken care of before deleting the Shifts in Salesforce


  • If the Shifts are to be deleted only in Salesforce then any Salesforce user can delete the Shifts,
  • And if the Shifts must be deleted both in Salesforce and on the V4S Kiosk application, then only the Salesforce user who has access to the V4S Mobile objects should delete the Shifts in Salesforce
  • Delete all the Shift related records in Salesforce: Delete the Volunteer Recurrence schedule, Job recurrence schedule, volunteer Hours related to the Shift that you wish to delete. If all these are not deleted in Salesforce, then the shifts deleted in Salesforce still show up on the V4S Kiosk application.


If the Shifts are regularly deleted by a Salesforce user in your org who does not have access to the V4S Mobile objects. Then you can write triggers (as mentioned below) in your Salesforce org so that the Shifts deleted in Salesforce do not show up on the V4S Kiosk application.


trigger sendFcmShift on GW_Volunteers__Volunteer_Shift__c ( after update, after insert, after delete ) {
    try {
       
        List<GW_Volunteers__Volunteer_Shift__c> Obj_list_delete = new List<GW_Volunteers__Volunteer_Shift__c>();
        if ( Trigger.isAfter) {
            // // This takes all available fields from the required object. // To get List of History tracking fields of Project
           
                 List<Object> Obj_list_update = new List<Object>();
                 List<Object> Obj_list_insert = new List<Object>();
                 Map<String, Schema.SObjectField> mapFields = Schema.SObjectType.GW_Volunteers__Volunteer_Shift__c.fields.getMap();
                  if (trigger.isDelete) {
                      for ( GW_Volunteers__Volunteer_Shift__c proj_fcm : trigger.old ) {
                          Obj_list_delete.add(proj_fcm);
                      }
                      SendFCM.sendFCMRequest(Obj_list_delete,'GW_Volunteers__Volunteer_Shift__c','delete');
                   } else {
                      for ( GW_Volunteers__Volunteer_Shift__c proj : trigger.new ) {
                        if ( trigger.isUpdate ) {
                          Obj_list_update.add(proj);      
                        }
    
                        // on Create/Insert
                        if ( trigger.isInsert ) {
                            Obj_list_insert.add(proj);
                        } 
                    }     
                    //System.Debug('Obj_list' + Obj_list );
                    
                    //Submit to Dftly server
                    if (Obj_list_update !=null && !Obj_list_update.isEmpty() ) {
                      SendFCM.sendFCMRequest(Obj_list_update,'GW_Volunteers__Volunteer_Shift__c','update');
                    }
    
                    if (Obj_list_insert !=null && !Obj_list_insert.isEmpty() ) {
                     SendFCM.sendFCMRequest(Obj_list_insert,'GW_Volunteers__Volunteer_Shift__c','insert');
                    }
               }  
        }
    } catch (System.CalloutException e){
         System.debug('ERROR:' + e);
    }   
} 


Note: The above trigger can be written in Salesforce if you are deleting Shifts, and if you want to delete Jobs without Shifts, you can mark the Job as Inactive in Salesforce. The jobs marked as inactive are not displayed on the V4S Kiosk application.