New answers tagged

0

I think you've got how to handle the code. I think you just need to understand a little more how the batch scope works. No need to re-query for the records. That's what the scope is for. Your start method actually handles the query and then breaks it up into chunks (default is 200, but you can define smaller if you want) which is passed to the scope for the ...


2

Your unit test needs to call the method: @isTest static void testScheduleMe() { Test.startTest(); ContUpdateScheduler.scheduleMe(); Test.stopTest(); } Coincidentally, this will cover the execute method as well.


0

I'm obviously am not familiar with your particular org, but from experience, it's not best practice to assume a duplicate programmatically based solely on the Name of an Account. Introducing a secondary layer of complexity by also checking Postal Code would give you a more accurate result, but it's still advised to be cautious. Im not sure about the volume ...


2

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_scheduler.htm Use it twice (0 1 0 15 * ?) (0 1 0 L * ?) I haven’t tried, but it should work!


0

In your start Method filter is Rent_Due_Date__c = TODAY In test class,You need to provide the value for Rent Due date Tenant__c tenant = new Tenant__c(); tenant.Name = 'TenOne'; tenant.Rent_Due_Date__c = System.today(); tenant.Property__c = property.Id; ten.add(tenant); insert ten; //Create Invoice records as well If start method ...


1

This isn't valid Apex and is not how you invoke a batch class: UpdateUserDataShedule.execute(Database.BatchableContext BC, List <User> scope); To run a batch class, create an instance of the batch and call Database.executeBatch(), just like you do in your Schedulable class: UpdateUserDataBatch u = new UpdateUserDataBatch (); Database....


0

The schedulable class should have the form you have described. The basic content of the batch class should be of the form: global without sharing class BatchProcessName implements Database.Batchable<SObject> { global Database.QueryLocator start(Database.BatchableContext bc) { string qry = 'SELECT id FROM somewhere'; return ...


1

Is it allowed to fire platform event from event trigger? YES, no problem Are there any limitations of how many platform events can be fired right from event trigger? Each EventBus.publish method call is considered a DML statement, and DML limits apply. See doc. So, you could publish 10,000 events (as that is the limit for DML Rows) Publishing limits (...


1

You're missing a return type on addColdCustomerToList. Add void, for example. Also, addressColdCustomers is undefined. You should give us complete code... it feels you're missing a lot here


1

In this line: ev.StartDateTime = Datetime.valueOf(Datetime.now().hourgmt()+24); seems that you want to add 1 day. You do not pass a date, so it resets to 1970-01-01. You should change it to: ev.StartDateTime = Datetime.now().addDays(1); Also, in DateTime dd = Datetime.valueOf(Datetime.now().hourgmt()-16); you should replace it with: DateTime dd = ...


0

You can refer to them in the same way you do any other property. If you wish to obtain an Id, you can do it this way: Case.SObjectType.getDescribe().getRecordTypeInfosByDeveloperName().get(<MyNameHere>).getRecordTypeId(); (Note that uses the API Name, not the label) If you're writing a query, you can do it this way: ... RecordType.DeveloperName IN (...


2

The main problem in your code is that you're doing a DML and a callout inside of a for-loop. This is a fairly large no-no and is going to cause you to hit Governor limits very quickly. It is also going to cause the error you're seeing. Here you need to do two things: Change your code to do one DML for the entire transaction, see below for an example If the ...


0

The other answer is partially correct, but I don't agree with the entire prescription and elements of it are incorrect. The root cause is that your variables are not defined. public String Subject{get;set;} Public String Body{get;set;} Public String attname{get;set;} Public blob attbody{get;set;} These are all null. You're not populating them here, and if ...


0

Use Database.Stateful interface, and then send the email in the batch's Finish method. Notice two things here : 1.Database.statefull Interface 2. declared global variable instead of local scope Please check the rough Skeleton: //use database.statefull Interface global class AttachmentEmail implements DataBase....


0

Anybody who had the similar issues like mine, this is the way I was able to solve this. Actually I posted the same question to Salesforce developer forums, Andrew there helped me out. I will put in his explanation and his code below: Andrews explanation: Loop the raw data to build a list of elements that you want to use in your query. e.g. street and city ...


2

Here you have assignment: acnt.RecordType.Name = 'Large Organisation' || acnt.RecordType.Name = 'SME/SOHO Organisation' instead of comparison: ac.RecordType.Name == 'Large Organisation' || ac.RecordType.Name == 'SME/SOHO Organisation' That is the error you're getting: "Expression cannot be assigned" The second error happens because you ask for acnt ...


1

You need to explicitly get the list of related objects via getSObjects() method for (ScheduledBillRun__c sbr : scope) { System.debug(sbr.getSObjects('Invoices__c')); }


2

Id <variable name>= Database.executeBatch(new <Class name>(), batch size); Example code Id batchJobId = Database.executebatch(new Batchtest() , 200); Where 200 is your scope.Scope is not mandatory. If you do not pass scope, default is 200 and maximum you can set is 2000. Note: batchJobId will contain the job Id of the batch.


2

But our production environment has lot of jobs scheduled and running.So wondering if queueable jobs are queued until after the rest of the batch apex jobs are completed. No. The system uses heuristics to ensure that all customers get a fair chance at executing their asynchronous processes, and within a single organization, jobs are approached in a sort of ...


Top 50 recent answers are included