The Stack Overflow podcast is back! Listen to an interview with our new CEO.

New answers tagged

0

You must be calling batch instance from a method that is called from the constructor of the Visual Force page controller or you must be calling batch instance from the constructor itself. try and call that batch instance from a method that is called on the action of Visual Force page. Note : you cannot call batch from constructor


0

You should use Databse.SaveResult for individually checking success/failure of each record update or insert. if(!contactToUpdate.isEmpty()){ Database.SaveResult[] updateResults = Database.update(contactToUpdate, false); List<SIS_Staging__c> errsStaging = new List<SIS_Staging__c>(); for(Integer i=0;i<updateResults....


0

Use Database.insert which is partial insert the collection of data, please read Database.insert() Doc List<Database.SaveResult> saveResultList = Database.insert(insertList, false); // Iterate through saveResultList based on isSuccess capture the failed records for (Database.SaveResult sr : saveResultList) { if (!sr.isSuccess()) { // ...


2

Use left instead: z.Patient_Id_Help__c=z.Patient_Name__c.left(10); It does not throw an exception if there is less than 10 characters. Remember to check for null first, if applicable: if(z.Patient_Name__c != null) { z.Patient_Id_Help__c=z.Patient_Name__c.left(10); }


0

For protected Custom Settings you will not be able to see the records in the subscriber org, but actually these records will be present. You can use System.debug to debug it and make sure you have these records and store debug information in custom dedicated object like Debug_Log__c


3

You can just use iterator instead. It should work if you do a pattern like the following: public with sharing class MyBatch implements Database.Batchable<SObject> { final List<SObject> records; public MyBatch(List<SObject> records) { this.records = records; } public Iterable<SObject> start(Database....


1

There is no SLA for asynchronous process as to when it will execute or finish. This means Salesforce would decide when it will run, and if your instance is shared with a big client that uses a lot of Async Apex, it's you who would get a penalty for it. I have seen 24 hours to execute a future job. You should raise with SF support, I have seen jobs get ...


0

I hope this is not the only way, but if it is, then you should definitely write your test in this syntax. try { ApprovalTriggerHandler.bBypassTrigger = true; System.debug('Statement after insert.'); // Insert other records } catch (Exception e) { ApprovalTriggerHandler.bBypassTrigger = false; // Handle this exception here } Otherwise ...


1

The maximum number of SObjects a batch can process depend on the type of object returned from start. Iterable - the maximum number is 50000 since this is the maximum number of rows that you can query from the database in a session (the iterable is an in-memory representation of the whole set of objects to be iterated) Database.QueryLocator - the maximum ...


5

The only practical limit on batch size is how long you want your batch to run. A batch can iterate over millions of records. Would limiting the scope of the execute batch method to say 1 potentially cause reaching governor limits? Setting a scope size of 1 will reduce your risk of governor exceptions, but increase overall run time of your job. Does ...


4

You can send any type of serializable data in to a batchable class, including virtually any type of Map collection. If you try to send in "invalid" data, you'd get an error specific to that process, not a generic NullPointerExeption error. The problem is in the constructor of your batch class code. You can prove it to yourself that the constructor is the ...


3

It should be as simple as using a Queueable with Database.AllowsCallouts instead of using a future method. See the product documentation for details. There are lots of alternatives you could consider in terms of the over-all approach, such as generating platform events with the JSON (as text) in them, but this approach does keep it clean and simple.


0

The approach you took will work but as you implemented Database.Stateful and adding all your processed data to the map chances are there to get heap size exception. You can bypass this by calling another asynchronous process (take an example of Queue) after all data processed. Batch_A { global void execute(Database.BatchableContext BC, List<Sobject&...


1

1)You have not released the memory of unused variables, which will lead to a heap size error if the number of records are more after the CampaignMember query. e.g - extIdsByKeys,optCTypeByYear 2)You have done update campaignMembers; without checking the list size, so if the number of records crosses 10k it will throw an exception. You have to takeout the ...


5

There's no rule that says you can't use a built-in List object, if your JSON is formatted that way: public class BatchInsert implements Database.Batchable<Object> { public String jsonString; public Object[] start(Database.BatchableContext context) { return (Object[])JSON.deserializeUntyped(jsonString); } public void execute(Database....


Top 50 recent answers are included