Tagged Questions

Classes implementing the `batchable` interface are used when there is a need to operate on a large number of data records which would normally be problematic due to the imposed governor limits.

learn more… | top users | synonyms (1)

1
vote
2answers
33 views

Can any one correct this one why batch apex is not deleting records?

Here is my batch apex .it is not deleting records global class BatchProcessorder implements Database.Batchable<sObject>{ String query; DateTime lastTwoDays = ...
0
votes
0answers
14 views

Batch apex error “Apex CPU Time limit exceeded error” [duplicate]

I have created batch apex class to insert records into salesforce but i got an error i.e."CPU time limit exceeded error" Please help me to solve this error. global virtual class InsertProductData ...
1
vote
0answers
24 views

Batch Iterable (Apex CPU time limit exceeded) List<Map<>>

I'm not sure what I'm doing wrong with my Batch Iterable class. I'm trying to create a List of Maps. I'm passing in an entire Map (accountToNewAndOld) which gets broken up into and added into a List ...
0
votes
0answers
34 views

Any work around to run 100+ jobs run or way

While saving 100+ jobs at a specified time i am getting error "You have exceeded the maximum number (100) of Apex scheduled jobs" If i want to use one scheduler to run all , we gonna have two issues. ...
1
vote
1answer
18 views

Database.DeleteResult.getErrors() question

I am trying to connect specific records that fail to delete in my batch job to their error messages. I thought my solution was working, but I checked the size of .getErrors() and it's size 1. My test ...
3
votes
1answer
44 views

System.AsyncException: Database.executeBatch cannot be called from a batch start, batch execute, or future method on batch within batch

I am attempting to call a batch within a batch. The reason why I am attempting this is because the values returned in the main batch is used in a query to grab other records to be updated from a ...
0
votes
1answer
29 views

Batch apex error in apex job : Exceeded max size limit of 3000000

Using Batch apex i am trying to Insert new records in to custom object from json string in salesforce from API url. When my batch apex class run i got this error in apex log. please explain me
2
votes
1answer
23 views

Performance impact of relationship queries in batch start

For a new batch process I have a choice between immediately selecting relevant records in the start function (but using several [field]__r comparisons as they are junction objects being queried) or ...
3
votes
1answer
18 views

Why should a queryString variable in an apex batch class declared as global?

Every documentation on batch apex class shows the queryString variable declared as global. Is there a specific reason for doing so??
0
votes
0answers
11 views

Batch Processing: “Read Timed Out” Error

I am trying to add records from API URL using batch apex in salesforce. I got an error while running batch apex. Please help me to solve this error.
0
votes
1answer
21 views

@future solves ERROR: MIXED_DML_OPERATION but Batch fails

A user is automatically created in the backend whenever a contact is created in the sf console. A custom field, DivisionCs is filled during that automated process. We want the same field to be updated ...
3
votes
2answers
63 views

SOSL query in Batch apex

Can a SOSL query be used in the Batch apex start method? I used the below code global Database.QueryLocator start(Database.BatchableContext BC){ return Database.getQueryLocator([FIND '.com' ...
-1
votes
1answer
56 views

Using Batch APEX to generate template body dynamically with merge field values

I am using Amazon SES to send mails to the all opportunities using batch apex with the body of email template. I'm using the solution proposed in an answer to Using APEX to assemble HTML Letterhead ...
0
votes
0answers
23 views

Design Approach: Apex Callout limits

I am developing an appexchange managed application intended for multiple subscribing organizations and as a part of requirement my managed application needs to make an extensive API callout to an ...
1
vote
1answer
77 views

Using Batch apex Insert new records in to custom object from json string in salesforce

I am trying to insert json data in to salesforce objects. Json string is too large so i am using batch apex to insert data. For this I had written apex class i didn't got any error But records not ...
2
votes
0answers
54 views

Accessing Custom Labels through Batch Apex

We have a mobile application which needs custom labels for different languages through Salesforce custom labels. Because of API limit on metadata api, we are planning to store all the required custom ...
1
vote
1answer
41 views

Can we create .csv file with a Batch Apex

Can we create a batch class where we can query the records and generate a .csv file . I have to automate the process and team is not interest in having a server where i can host the Command line ...
3
votes
0answers
41 views

Batch Apex gets stuck in Queued status for a long time

We have an apex job that gets stuck in "Queued" status for a long time before going into "Processing". This happens only in Sandbox environment (which was recently refreshed from Prod btw) and not in ...
1
vote
1answer
18 views

How do I create/update bulk records in one execution synchronously?

I have object A which has 2 Lakh records. A child has to be created under each of these records on a click of a button and show them on a vf page. I am hitting a lot of limitations like 1) 50001 ...
1
vote
1answer
54 views

code coverage for the test class

i have a batch class which i am scheduling for run. and i have a test class for the batch class. the batch class is working fine . but the code coverage is 44% . important note: when the batch ...
0
votes
1answer
40 views

Found null SObject at position 0 in data taken from Batchable Map

I am running the below code but getting a DML error for my database.delete statement found null SObject at position 0 error. global class RevenueSchedulerBatch implements Database.Batchable ...
1
vote
0answers
41 views

How to get the value from a batch apex class to a normal apex class

So I've created a batch class, did a query, and stored the results into a map. Now I know that you can pass values from one batch to another with cascading batch calls and database.stateful, but is ...
-1
votes
0answers
23 views

Catch block code coverage in batch class

The line just above and below the catch blocks are not covered in apex test class.I tried isRunning Test() but no help. https://success.salesforce.com/ideaView?id=08730000000kwlYAAQ#. This link says ...
0
votes
1answer
64 views

batch class execute() method not covered by test class

Need to raise the covered line on this apex code could you kindly point out the missing piece of code for my test class. It does not covered the code in bold face (global void ...
1
vote
1answer
37 views

Can you run a Batchable Apex bulk update as a different user?

I have been running my Batchable Apex bulk update from the developer console so it runs with my permissions. Is it possible to run it as another user? Ideally I'd like to run it under the API profile ...
0
votes
1answer
36 views

How to manually give a callout in test class

I needed to throw a callout exception by hardcoding it in test class for batch class.Is there any method to do that ? try{ XXXX } catch (CalloutException excpObj) { ...
1
vote
0answers
26 views

How to populate a map using Batch

So I have to create a map using an object implementing the batch interface. I have used the Database.stateful interface to make sure all instances of the batch are inserting into the same table. The ...
0
votes
1answer
25 views

How can I know if it's the last execution of all the batches?

I have a shared Map type instance variable that I want to process after all batches are executed. public Map<String,List<ID>> territoryClientIDMap=new Map<String,List<ID>>(); ...
-1
votes
1answer
38 views

How to use report result as input to Batch Apex

Let's say I have a report with a specific result. Now i want to process this result in a batch process when the user triggers a order-button/link. Is there a way to have a button on the report page ...
0
votes
0answers
44 views

Updates by apex class are partially successful,unable to debug

I have a batch apex class in production that deals with custom objects Call2_vod__c and Hcp_Depth_Tracker. Finds out number of calls with same Account field and Territory field value and updates the ...
1
vote
0answers
80 views

error from test method - “apex job is already scheduled for execution”

I have a batch apex which starts itself after x mins. this is done in finish() method using , system.scheduleBatch() method. below is how the batch looks like, global class my_ProcessPurge_Batch ...
0
votes
3answers
51 views

Batch apex failling silently for some records

I am writing a batchable apex class and am finding that every time I run it, some rows are not being processed. The strange thing is when I look at the apex job monitoring page, the number of ...
3
votes
0answers
53 views

Best way to bulk update data in salesforce

We have created a trigger that generates some information for a column on the Opportunity object. We now want all 400,000 existing opportunities to have the same information. The logic is encapsulated ...
2
votes
1answer
58 views

Are static variables reset per batch during bulk DML operation? (Executing triggers for field updates)

A while back I had a trigger issue where I needed a trigger operation to execute exclusively on the second update or an update after an insert. So I had some code like this: Trigger Handler Class ...
1
vote
1answer
27 views

How does the batch execution fetch records to do any operations

Okay, I have huge set of records in a Custom object and i'm fetching these to do some kind of DML operations. During this batch process, how exactly does the records are fetched as in what order and ...
0
votes
2answers
36 views

Batch Class CallOutLimit Doubt

As we have 10 callout governor Limit in each execution . So I can query 100 records in start and execute the batch class with batch size as 1 and do 10 callout for each record . So total I can query ...
1
vote
3answers
97 views

Batch Class shoudnt go to execute on certain condition

I have a logic in which sometimes I dont need to execute a batch class execute method. How to achieve this as we cannot pass null or whitespace in query locator
1
vote
0answers
53 views

Add/Remove Campaign Members Based on Contact List using Apex

I'm having a hard time figuring out the logic for this in Apex. In C# I would just use linq. I have an existing campaign that I want to add/remove members based on new lists of contacts. Basically, ...
0
votes
2answers
158 views

Apex CPU Time limit exceeded error

I have a batch apex class that is facing CPU time limit exceeded error. Can someone please help me to by pass this error here? Please find my batch apex here. global class Account_chk_batch ...
0
votes
1answer
48 views

Apex Batch: Query locator failure

I am facing an issue with the querylocator line here. My code snippet as below. global Database.QueryLocator start(Database.BatchableContext BC){ query = 'select Id,(select Name from ...
0
votes
0answers
17 views

Creating a class object in a method in different class and returning the object

How to create a class object in different class's method and return its object. The class is a batchClass whose object needs to be created and returned in different class. My code so far: public ...
0
votes
1answer
49 views

Apex error: Initial term of field expression must be a concrete SObject

I have to update bulk records by apex class which is called from an apex trigger. Please find my class and trigger below. Batch class: global class UpdateAccountArea implements ...
4
votes
0answers
32 views

Can batchable custom iterables support null values?

Background We're trying to do a type of pseudo-parallel processing mechanism, where a record will be processed twice. The thought was to make an overlapping series of values that look like this: ...
1
vote
1answer
32 views

Code efficiency help: Can't avoid CPU limit (even with batch)

I'm at my wits end guys. I've rewritten my code a half dozen times now. First I though I could increase efficiency with my loops and if clauses, then I started incorporating tips I read using maps ...
0
votes
2answers
48 views

SOQL Query for month operator

I have to compare month value of a custom object's date field, if it is of the current month. Please find the piece of code below. I am getting error here. Can someone help me? Code piece: ...
6
votes
2answers
78 views

Is it possible for Database.executeBatch() to execute before the parent transaction is committed?

Previously, I would have assumed definitely not, but we recently ran into an issue where we have a large transaction (via VF page) which inserts a ton of rows under a parent object. Then it calls ...
3
votes
1answer
282 views

Future method cannot be called from a future or batch method, Case Trigger with Salesforce for Social

I get the following inside a Case Trigger when I try to call a future method: System.AsyncException: Future method cannot be called from a future or batch method So far this exception ONLY occurs ...
2
votes
1answer
61 views

Too many dml rows exception

I tried to insert records for call__c object which gives this exception Trigger: trigger trgInsertCall on Call__c (after insert) { Set<Id> clientIds = new Set<Id>(); ...
0
votes
2answers
276 views

Too many DML rows: 10001

I have a trigger which performs an insert operation.One record count is more than 10k.So,Its giving this exception.I have tried batch apex and future method.Its is not working.Any help will be ...
1
vote
1answer
26 views

Join Query to a Batch Handler and processing the result rows

Can we write a join query and pass on to a batch handler. Once I get all the rows, I want to dynamically fetch values using their fields described from the rows containing info of both the objects. ...