New answers tagged

3

In execute method parameter of the records is List<sObject> which is not a concrete SObject, but a general Sobject. In order, to get field values from Opportunity, you can cast SObject to Opportunity and use dot notation to get field value. public class MyBatchClass implements Database.Batchable<sObject> { public Database.QueryLocator start(...


0

use this to query: Id batchJobId = Database.executeBatch(new CostToBuild(), 50); test.stopTest(); AsyncApexJob aaj = [SELECT Id, Status, JobItemsProcessed, TotalJobItems, NumberOfErrors FROM AsyncApexJob WHERE ID =: batchprocessid ]; and validate in asserts.


1

Assuming combination of Postal_Code__c and Organization_Name__c returns only one account from org. You can do something like this: global void execute(Database.BatchableContext BC, List<Staging__c> scope){ Set<String> uniquePostalCode = new Set<String>(); Set<String> uniqueOrganizationName = new Set<String>(); for(...


1

The generic sObject can only access the Id field. You'll want to change: public void execute(Database.BatchableContext bc, List<sObject> scope){ To: public void execute(Database.BatchableContext bc, List<FlowInterview> scope){ This should fix all your compilation issues.


1

There are few compilation issue I see right from your code above. I see no closing curly braces at the end of the file. In Method searchAccount and searchContact params are list but your are expecting Single object while declaring the method. Method searchAccount does not have any return statement in else as the first return statement is inside if block. In ...


1

There were many errors in the code such that you are not looping the scope in the execute method, there were some issues regarding the open and close braces { and } and also ,. I have updated the code now i don't see any errors. global class BatchAssignment implements Database.Batchable<sObject>{ global Database.QueryLocator start(Database....


1

In your upsertRecs method you are returning null. You should return recList.


0

Use Queueable instead of Batchable for anything you want to do in a trigger. These have much higher limits per transaction (50), and can do pretty much everything a batch can do, except automatically handle millions of records. What you can do from there is pass in all 200 records into the queueable, and it can chain itself repeatedly to make the 200 ...


Top 50 recent answers are included