/** * ─────────────────────────────────────────────────────────────────────────────────────────────────┐ * This Batch class is use for delete all older log records more then 30 dys old. * Shopify API Documentation: https://shopify.dev/docs/admin-api/rest/reference * Create Shopify Store: https://www.shopify.com/signup?itcat=identity&itterm=create-new-store * Shopify API Release 2020: https://www.shopify.in/partners/blog/shopify-api-release-january-2020 * What is Person Account in Salesforce ? https://help.salesforce.com/articleView?id=account_person.htm&type=5 * ────────────────────────────────────────────────────────────────────────────────────────────────── * @author Sumit * ────────────────────────────────────────────────────────────────────────────────────────────────── */ global with sharing class Batchtodeletelogs implements Database.Batchable,Database.Stateful{ global Iterable start (Database.BatchableContext bc){ list listofshopifylog = new list(); date d = system.today().addDays(-30); listofshopifylog = [select id from HIC_ShopifySync__shopify_log__c where createdDate <= :d WITH SECURITY_ENFORCED limit 9999 ]; if(!listofshopifylog.isEmpty()){ return listofshopifylog; }else{ list listofemptyshopifylog = new list(); return listofemptyshopifylog; } } global void execute(Database.BatchableContext bc ,list scope){ try{ if(!scope.isEmpty()){ if(CheckAccessibility.isDeletable('HIC_ShopifySync__shopify_log__c')) Database.delete(scope,false); } }catch(exception e){ system.debug('getting errors when deleting logs'); } } global void finish(Database.BatchableContext bc){ system.debug('Delete logs successfully'); } }