New answers tagged

1

you are mixing here the concept of start and execute methods of Database.Batchable<sObject> interface. in start, you are writing a query, that defines what records should be processed in execute method. Just a filter for records that should be selected. In order to set size of records passed to execute method as a scope, use Database.executeBatch(...


0

There's a lot going on here, so I don't think I can share a comprehensive or conclusive answer, but I think the key is that run() has to complete before your Azure function returns a status: result = run(username, password, token, is_sandbox, master_territory, follower_territory) return func.HttpResponse(result) Then, in run(), you perform a SOQL query ...


1

If you are in a batch asynchronous context when parsing the CSV files then you total heap size of 12 MB applies. That should be more than enough to load in the approximately 2.5 MB of raw CSV data and then process it. You would be looking at about 5 MB of Heap usage all up, not including the Account and Address records you wanted to process. You mentioned ...


6

For my SObjectWorkQueue I am using batch chaining and serialized work records. It’s not a new approach but worked very reliably in the past for me. Not sure if I ever saw this penalty. https://github.com/rsoesemann/sobject-work-Queue  


0

Each invocation of execute() in an Apex batch class is a single transaction. The callout limit for a transaction is 100. While it's not clear what exactly Builder.getListOutBoundRecords() is doing, it appears to be sourcing more than 100 records at a time. Meanwhile, start() is identifying exactly one record: String soql = 'Select Id, JOB_ID__c from ...


3

Yes, you have a high likelihood - more like a certainty, really - of hitting a variety of limits in this scenario. We need to iterate through obj1, get its relevant records from obj2 based on Id and further query for permission of each object in the user permission table and make [multiple] external call outs for them. Obj1 has around 5 M records and each ...


0

It is hard to be sure this is answering the right question since (as @cropredy said) your question isn't really clear, but on the off-chance I am understanding what you need to do: Use of a batch to simply execute some logic to get an external value and store it is quite wrong - at the very least, this is going to consume 2 async apex executions per batch ...


0

See the below classes where the batch class is executed in an annonmous apex as below in first block hoping that you will be doing in a scheduled apex. In here you doo not need a getQueryLocator as you are not querying anything. Id batchJobId = Database.executeBatch(new ZuoraBatch(), 200); // OR you can pass it to the constructor if you like Database....


0

I would like to point Javascript driven execution: Javascript driven execution, where @RemoteAction methods are used from a browser to drive execution. Users have to keep their browser windows open. This is not the case anymore, with the growth of recent technology, you can run windowless browser via command line and write your scripts to run your VF page. ...


3

Personally, I have not seen Batches to be queued that long, even if they are it doesn't seem SF will kill them after some time if they are in limit. That being said, You can follow another approach. We know at max 5 batch jobs can run at a time. Let's utilize this and start the next batch at the end of each batch. RandomBatch bch = new RandomBatch(0); ...


0

You have to use middleware if that's not possible then another way would be to move the code out of apex to Lightning Component aura or LWC and then use Salesforce Rest API to download attachments, convert them to files and upload it back into salesforce. It would be faster as your faster desktop would be used for processing. The only drawback is you have ...


0

When using System.scheduleBatch, if you always use the same name every time for scheduling this batch, an attempt to schedule the batch whilst it is already scheduled will result in an exception and the batch won't get double scheduled. You can use the Async Apex Jobs table to provide info about whether the specified batch is already executing and you might ...


0

What is this custom logic you are referring to? You will not be able to escape the heap size limit when processing attachment body's in apex as the data will consume the heap space for an attachment of size > 12MB during async apex (i.e. calculating base64 string of the body). Actually, your upper bound in cases like this is closer to ~10MB because of the ...


1

Remove static from the method signature. It will work as expected. Go through batch apex document: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_batch_interface.htm


3

It seems to me this is very like your previous question, and likely has the same basic answer... The issue I see in your first batch is that the aggregate query does not limit the query for "maplastY" to those entries relevant to the bible instances in the scope. That means every call to execute will try to aggregate query over all 900000 telephone records ...


1

You can call batch from the previous batch finish() method. For example, Initial step to call in developer console or anonymous is Database.executeBatch(new RecursiveBatch(Date.valueOf('2019-01-01'))); Then you can use this stub. public class RecursiveBatch implements Database.Batchable<sObject>, Database.AllowsCallouts, Database.Stateful { private ...


0

CPU time limit is exceeding due to processing of large number of records with given logic. https://welkinsuite.com/blog/how-to-get-past-apex-cpu-limits/ Apart from this, you can call Batch class from Process builder or Trigger. You can try with Batch from Trigger and run it Async. Using Code you can put your logic to filter out only those records need to be ...


0

AsyncApexJob does not support triggers. You might be able to use a FOR UPDATE query to obtain a lock on your current job entry to see if it's been aborted, but this is, at best, going to be a race condition. There is no reliable method to determine a hard abort when the job is cancelled from within the job.


3

On the face of it, a Batch on Contract would be appropriate. I would write the batch to iterate the Contracts and have the execute perform the aggregate query and related processing. Your aggregate query would simply change to: public Database.QueryLocator start(BatchableContext context) { // You might like to restrict the contracts examined, e.g. to ...


2

The iterator's hasNext logic needs to be changed to: return i < objectsToCheck.size();


Top 50 recent answers are included