• Felix Leinert
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 3
    Replies
Hello together,

I have a scheduled an apex class (billonDailyUpdatesSched) that creates lists on different objects and pushes those lists into another apex class (billonMethods) in order to perform actions on all records collected in the lists.
However, apparently not all records were updated accordingly, although they meet the criteria to be included in the lists.
  • When I manually update the records, it works just fine. So there are no validation rules preventing the apex class from updating the records
  • I have the feeling that we hit the governor limits as too many records are touched by the apex classes at the same time. However, I do not know how to validate that.
Below is the code of the scheduled apex class. Thank you for any help in advance !
global class billonDailyUpdatesSched implements Schedulable 
{
    global void execute(SchedulableContext SC) 
    {

List<ONB2__Subscription__c> ActivatedSubscriptions = Database.query('Select Id, ... 
	from ONB2__Subscription__c 
	where((plReasonForInactive__c = \'CSD in future\' AND ONB2__Status__c = \'Inactive\' AND ONB2__StartDate__c < today) OR (ONB2__StartDate__c = today AND ONB2__Status__c = \'Inactive\' AND plReasonForInactive__c = \'CSD in future\'))');     

billonMethods.updateActiveSubscription(ActivatedSubscriptions);

List<ONB2__Item__c> terminatedItems = Database.query('Select '+Helper.fetchObjectfieldnames('ONB2__Item__c') +', ...
	from ONB2__Item__c 
	Where ((ONB2__Subscription__r.ONB2__AutoRenewal__c = null AND ONB2__Subscription__r.ONB2__EndDate__c = today) OR (ONB2__EndDate__c = today AND bRenewItem__c = false)) AND ONB2__Active__c = true');

billonMethods.updateSubscriptionItemToEndDate(terminatedItems);

List<Account> terminatedAccounts = Database.query('Select Id, ...
	from Account 
	where refActiveSubscription__c != null and refActiveSubscription__r.ONB2__AutoRenewal__c = null and refActiveSubscription__r.ONB2__EndDate__c = Today');

billonMethods.updateAccountTypeLifecycle(terminatedAccounts);

List<ONB2__Subscription__c> terminatedSubscriptions = Database.query('Select Id, ... 
	from ONB2__Subscription__c 
	where ONB2__AutoRenewal__c = null and ONB2__EndDate__c = Today');

billonMethods.updateterminatedSubscription(terminatedSubscriptions); 

Date dateMerchantExit = System.today().addDays(28);    

List<ONB2__Subscription__c> SubscriptionsOfExitMerchants = Database.query('Select Id, ...
	 from ONB2__Subscription__c 
	where ONB2__Status__c = \'Terminated in Due Time\' and ONB2__EndDate__c = :dateMerchantExit');

System.debug('========================================> This is the found Subscription: '+SubscriptionsOfExitMerchants);

Map <Id,Messaging.SendEmailResult> mapTargetObjectIdToResult = new Map<Id, Messaging.SendEmailResult>();

For (ONB2__Subscription__c sub : SubscriptionsOfExitMerchants) {
        if ((sub.ONB2__Account__r.ParentId != null && (sub.ONB2__Account__r.RecordType.DeveloperName == 'SME2015' && sub.ONB2__Account__r.Parent.RecordType.DeveloperName == 'SME2015')) ||
            (sub.ONB2__Account__r.ParentId == null && sub.ONB2__Account__r.RecordType.DeveloperName == 'SME2015'))   
        {
            
            List<id> listContacts = new List<id>();
            listContacts.add(sub.ONB2__Account__r.OwnerId);
            listContacts.add(sub.ONB2__Contact__c); 
    
            User userSender = [Select Id, Name, Email from User where Id =: sub.ONB2__Account__r.OwnerId LIMIT 1];
    
            systemEmail smReminderOfAccountClosing = new systemEmail('Reminder_account_closure', sub.ONB2__Account__r.plTemplateLanguage__c);
            mapTargetObjectIdToResult = smReminderOfAccountClosing.sendTemplateAsUser(sub.Id, userSender, listContacts);
        
        }
    }

Database.executeBatch(new billonCalculateMRROnAccountBatch());

if (Limits.getDMLStatements()>120||Limits.getDMLRows()>40000){Helper.sendErrorMail('Nearing DML Limits in billon Daily Updates: pls start preparing for Batch');}

   }
}




 
Hello together,

I received an error message from an scheduled apex class. The error was caused by a flow. However, I did not receive any email error message.
Is it possible to identify the affected flow by the Apex job ID?User-added image

Thank you very much for your help in advance!

Best wishes,
Felix
Hello together,

I have a scheduled an apex class (billonDailyUpdatesSched) that creates lists on different objects and pushes those lists into another apex class (billonMethods) in order to perform actions on all records collected in the lists.
However, apparently not all records were updated accordingly, although they meet the criteria to be included in the lists.
  • When I manually update the records, it works just fine. So there are no validation rules preventing the apex class from updating the records
  • I have the feeling that we hit the governor limits as too many records are touched by the apex classes at the same time. However, I do not know how to validate that.
Below is the code of the scheduled apex class. Thank you for any help in advance !
global class billonDailyUpdatesSched implements Schedulable 
{
    global void execute(SchedulableContext SC) 
    {

List<ONB2__Subscription__c> ActivatedSubscriptions = Database.query('Select Id, ... 
	from ONB2__Subscription__c 
	where((plReasonForInactive__c = \'CSD in future\' AND ONB2__Status__c = \'Inactive\' AND ONB2__StartDate__c < today) OR (ONB2__StartDate__c = today AND ONB2__Status__c = \'Inactive\' AND plReasonForInactive__c = \'CSD in future\'))');     

billonMethods.updateActiveSubscription(ActivatedSubscriptions);

List<ONB2__Item__c> terminatedItems = Database.query('Select '+Helper.fetchObjectfieldnames('ONB2__Item__c') +', ...
	from ONB2__Item__c 
	Where ((ONB2__Subscription__r.ONB2__AutoRenewal__c = null AND ONB2__Subscription__r.ONB2__EndDate__c = today) OR (ONB2__EndDate__c = today AND bRenewItem__c = false)) AND ONB2__Active__c = true');

billonMethods.updateSubscriptionItemToEndDate(terminatedItems);

List<Account> terminatedAccounts = Database.query('Select Id, ...
	from Account 
	where refActiveSubscription__c != null and refActiveSubscription__r.ONB2__AutoRenewal__c = null and refActiveSubscription__r.ONB2__EndDate__c = Today');

billonMethods.updateAccountTypeLifecycle(terminatedAccounts);

List<ONB2__Subscription__c> terminatedSubscriptions = Database.query('Select Id, ... 
	from ONB2__Subscription__c 
	where ONB2__AutoRenewal__c = null and ONB2__EndDate__c = Today');

billonMethods.updateterminatedSubscription(terminatedSubscriptions); 

Date dateMerchantExit = System.today().addDays(28);    

List<ONB2__Subscription__c> SubscriptionsOfExitMerchants = Database.query('Select Id, ...
	 from ONB2__Subscription__c 
	where ONB2__Status__c = \'Terminated in Due Time\' and ONB2__EndDate__c = :dateMerchantExit');

System.debug('========================================> This is the found Subscription: '+SubscriptionsOfExitMerchants);

Map <Id,Messaging.SendEmailResult> mapTargetObjectIdToResult = new Map<Id, Messaging.SendEmailResult>();

For (ONB2__Subscription__c sub : SubscriptionsOfExitMerchants) {
        if ((sub.ONB2__Account__r.ParentId != null && (sub.ONB2__Account__r.RecordType.DeveloperName == 'SME2015' && sub.ONB2__Account__r.Parent.RecordType.DeveloperName == 'SME2015')) ||
            (sub.ONB2__Account__r.ParentId == null && sub.ONB2__Account__r.RecordType.DeveloperName == 'SME2015'))   
        {
            
            List<id> listContacts = new List<id>();
            listContacts.add(sub.ONB2__Account__r.OwnerId);
            listContacts.add(sub.ONB2__Contact__c); 
    
            User userSender = [Select Id, Name, Email from User where Id =: sub.ONB2__Account__r.OwnerId LIMIT 1];
    
            systemEmail smReminderOfAccountClosing = new systemEmail('Reminder_account_closure', sub.ONB2__Account__r.plTemplateLanguage__c);
            mapTargetObjectIdToResult = smReminderOfAccountClosing.sendTemplateAsUser(sub.Id, userSender, listContacts);
        
        }
    }

Database.executeBatch(new billonCalculateMRROnAccountBatch());

if (Limits.getDMLStatements()>120||Limits.getDMLRows()>40000){Helper.sendErrorMail('Nearing DML Limits in billon Daily Updates: pls start preparing for Batch');}

   }
}




 
I am using the outbound messaging scenario, wherin an outbound message is triggered on accomplishment of a 'workflow rule'. 
It is working fine and the opportunity records are sent to my web service and the acknowledgement is sent back to Salesforce.
My question is that wont there be any security concerns since no login parameters/ credentials were used while logging into the server that hosts my webservice. Moreover, while the acknowledgement was sent back to Salesforce, there too there is no such security application.
Please guide me on the following:
How does salesforce manages secutiry in outbound messaging?
Do I need to opt for some other way of communication which is more secure?
Am I missing something and there is an option to apply security parameters in outbound messaging as well?