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

-3
votes
1answer
38 views

Running an Apex batch

I created an apex batch, I configured it with the schedule jobs in order to run monthly, I want to test if it works or not. Have I write a Test class or execute it in anonymous and how is gonna be ...
4
votes
1answer
171 views

Future vs batch

I need to make asynch call from trigger. Records are comming (1 or 1000 at once) each minute and I need to process them from trigger asynchronously. As I see limits for future and batch jobs are the ...
0
votes
0answers
38 views

Apex Batch that triggers class code

I have this class that implements an API, right now this class is linked to a SF Page with a button, I was wondering if it is possible to make this process automatic without any human interaction (as ...
3
votes
1answer
23 views

Shoudl I use batch apex to count large sets of related records?

Here's the scenario: I have 1 million + 'Usage Data' records, which are related to Contracts via a lookup field. I want to get a count of the number of Usage Data records on each Contract. My ...
1
vote
3answers
64 views

How to create schedule batch apex which returns list of object records?

Hi I am new in salesforce, and I want to create a Schedule Batch Apex that will query for any Contact and For each Contact returned create an Opportunity. I have written the following code for this: ...
1
vote
2answers
55 views

Got DUPLICATE_VALUE exception with value : <unknown> and record id: <unknown> in a batch

I got the following exception on a batch job: System.DmlException: Insert failed. First exception on row 0; first error: DUPLICATE_VALUE, duplicate value found: <unknown> duplicates value on ...
1
vote
0answers
41 views

Creating attachment(document record) through batch apex when size greater than 5MB

I wrote batch class which creates a excel file in documents folder. But my problem here is when the size of excel reaches 5MB then the heap size error is shown and batch fails after certain ...
0
votes
1answer
27 views

Visualforce mass update

I have a visualforce page which display number of records.user can select multiple records at same time.and on submission some mass update related to this records should happen. we are thinking of ...
3
votes
2answers
66 views

Scheduled batch “already scheduled”

I had a batch job that I tried to start. Its "startup" method that launches it checks to see if it's already running by querying the asyncjob object, then starts it only if it's not running already ...
3
votes
1answer
24 views

DMLException.getDmlId() returning null

In a batch Apex class, I've wrapped the DML statements in a transaction and try/catch block, looking for DMLExceptions. When I catch the exception and call getDMLId(), it just returns null, which is ...
2
votes
2answers
38 views

Testing batch apex question

I'm working on a batch job that will change a lead record's Owner when the record was created over 15 minutes ago and is still owned by a particular user. Here's the batch job. This works in ...
1
vote
2answers
36 views

Apex - how to batch update a 'ranking' on all accounts

For a simplified example, assume that all our accounts have a ranking based on revenue. Every month I want to update these rankings based on new accounts that were added. Assume we have 50,000 ...
2
votes
2answers
52 views

Creating attachements in batch apex

How can I create a attchment for each batch data in batch apex- I have written batch class to delete 1 million records through batchapex, now I want to have the backup of all the data before deleting ...
-1
votes
2answers
31 views

Is it advisable to call Batch from trigger

I was thinking of calling a batch class from my trigger. Is is advisable to do that? As batch will have asynchronous execution with respect to trigger.
-2
votes
2answers
40 views

How to write the Query in batch class

is this correct query or not. this is batch class query but i did't get the values any one can tell me Query: 'SELECT Id,RRD_No__c,Exist_in_Abacus__c,Status__c FROM Demand__c WHERE ...
1
vote
1answer
50 views

how to write test class for batch class?

can any one give the sample test class for this code i am not awareness in testing please help me. global class SearchAndUpdate implements Database.Batchable<sObject>,Schedulable{ global ...
2
votes
0answers
34 views

Batch Apex: Invalid field StageName for OpportunityHistory

In my SalesForce managed package I have a Batch Apex job that queries OpportunityHistory and does some post-processing (basically serialize them and posts to external Web Service) When I schedule and ...
0
votes
1answer
29 views

Update custom object from Email service attachment

The use case is sending an attachment(csv) to my email service ; in the email service i will parse the csv ; each line of the csv will have values like key1,key2,value1 I have to query the custom ...
1
vote
1answer
164 views

UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record

I have a batch process which updates Accounts and sometimes when i run this batch i get the error. UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record I did read through Mohit's ...
1
vote
1answer
24 views

Changing org-wide sharing settings from Apex

We have an object whose Org-Wide default sharing setting is set to Private. When an Admin changes a Picklist to Full Access, we have to insert CustomObject__Share records for all users, and ...
0
votes
1answer
53 views

how to test the batch code?

How to write test class for this code 75% coverage or not? global class SearchAndUpdate implements Database.Batchable<sObject>,Schedulable { global final String Query; public ...
3
votes
2answers
88 views

Problem Invoking Batch from Button

I am trying to invoke a batch from a button. I can see in the debug log that the database.executeBatch line is being executed after the button is hit, but it never really invokes a batch job, yet ...
1
vote
1answer
145 views

how to update picklist field according to another object?

I have two objects: object1_c contain sds_c field this is text data type and sds_chek__c this is picklist field (picklist values "Yes/No") object2_c contain sds_c field this is text datatype Here ...
5
votes
2answers
90 views

What is the purpose of Global and Final modifiers in Batch Apex?

I've noticed that Batch Apex classes are all global, and the dev console returns an error if you just try to do a public/private class. My understanding is that a global class is visible to all ...
7
votes
2answers
350 views

generating PDF of a record's printable view in batch apex

Some of my users cannot view the Case object owing to restricted licenses. To avoid paying for service cloud licenses, I need to generate PDF snapshots of all Case records using a batch (the are many ...
-1
votes
1answer
154 views

Batch apex class to update a field [duplicate]

The requirement is i need to write a Batch Apex Class to update Case status field to close when related tickets field status is closed. The update of status should be after 7 days of all the tickets ...
0
votes
0answers
33 views

The batch job that changes Income Timing every new quarter is not working

global class QuarterlyRollupBatch implements Database.batchable<Opportunity>{ Public Date lastDateOfThisQuarter,fiscalYearStartDate,firstDateOfNextQuarter; Public Integer quarter; ...
1
vote
1answer
42 views

Batch Query Based on Custom Setting

I have a batch class that runs on all leads unless the user has entered a specific lead Record Type into a custom setting field. I'm getting an "System.QueryException: Invalid alias" even though when ...
0
votes
2answers
49 views

calculating trailing 3 months revenue

I have an sObject, which has Sales_Rep_c, Month_c and Year_c variables and corresponding revenue in Revenue_c variable. For this combination, I want to create a new formula field to calculate the sum ...
0
votes
0answers
154 views

Scheduled Batch Apex class

I need to write a Scheduled Batch Apex Class on two Objects Case and Ticket__c. Note: Ticket__c Has a look up to the Case. So, a case can have multiple tickets but a ticket can only be associated to ...
0
votes
1answer
69 views

How to rollup opportunity count up to top level account?

Use Case I Wanted to roll up opportunity count to the top level account. for e.g account a=2 opps child of account b=4(+2 own opps) child of account c=6(+2 own opps). For this i have created a roll ...
1
vote
1answer
77 views

How to find accounts with no child accounts using soql?

I have requirement where i need to process account which has no child but has parent and accounts which has no parent and child separately. I tried select id, name,(select id, name from Accounts) ...
0
votes
0answers
68 views

Help writing ScheduleBatch Apex class

I have to write a Schedulebatch apex class on two objects Case Ticket__C Ticket__c has a lookup to case and a case can have many ticket records but a ticket can only be associated to one case ...
1
vote
2answers
115 views

Test Batch that call HttpCallOut method using MultiStaticResourceCalloutMock

I have read several document regarding this ,including Testing webservice call out but still I cannot find the solution for my issue. I am creating test method to test batch class that contain ...
6
votes
1answer
152 views

How to pass the webservice results as an input list for a batch apex class?

i read the documentation and it has been given like the one given below. global class UpdateInvoiceFields implements Database.Batchable<sObject>{ global final String Query; global final ...
0
votes
1answer
55 views

Can a schedule be executed from future method?

One cannot execute a batch from a future annotated method. It is also impossible to have a trigger reacting to changes in future calling a batch. I cannot find if it is possible to execute a schedule ...
2
votes
1answer
212 views

System.LimitException: Too many callouts after set batch scope 1

I read the documentation here regarding batch execution.I have batch class that call Http call out from another class.All together need to execute 6 HttpCallout per record.I cannot separate the ...
7
votes
2answers
136 views

Is there a programmatic way to tell if an Apex class is batchable?

Is there a programmatic way to determine which Apex classes in my Org are batchable (i.e. implement a batch interface)? I have looked at the Metadata API but it does not seem to have any method for ...
1
vote
1answer
60 views

Page break in PDF sending by batch class

I am sending a PDF through batch class. In PDF there are some tables. I want new page every time a new table starts in pdf. How can I achieve this??
1
vote
1answer
142 views

Processing callouts from Batch

I have a tough scenario where a future method should be called from a batch.I came across various articles stating that it is not possible. My scenario is i need to send emails for contacts of account ...
0
votes
1answer
61 views

How to write batch apex?

I am new to Salesforce. So a help is required from you guyz. I want to write a Batch Apex, where I want to update some value of Account (lets say Name). and then from before trigger I have to call ...
8
votes
2answers
604 views

Calling future method from Batch

I have a requirement where a future method need to be called from batch apex ,I came across various articles stating that a future method could not be called from the batch. Is there any alternate ...
5
votes
1answer
315 views

Apex Batch job limits not clear Queued vs Scheduled

We have a discussion going on, to know now exactly what the limits are on batch apex jobs. The docs are really not clear on this. In this document it states that "Up to five queued or active batch ...
2
votes
2answers
83 views

Batch Apex to trim leading zeros

Can I write a batch apex to trim leading zeros from couple of fields. There are 2 number fields with around 1 million records with leading zeros. Batch apex or any other way? Which should be much ...
3
votes
2answers
240 views

How do you use getQueryLocator(sObject[])?

I'm getting an error 'Argument must be an inline query' on the return line. Does that mean I need to make a query of my sObject in the parameter of the getQueryLocator() as opposed to passing in a ...
5
votes
2answers
724 views

Scheduling batch Apex

Hi this is my batch apex code global class batchAUpdate_based_on_stage implements Database.Batchable<sObject> { global Database.QueryLocator start(Database.BatchableContext BC) { ...
1
vote
1answer
255 views

How to schedule Batch Apex to run once in a year

I'm a very much new to apex coding and I'm stuck with this problem kindly help to come out of this problem. Scenario : I have a one custom object called child__c and i have a custom field by name ...
7
votes
1answer
77 views

Avoiding Mixed DML (setup/non-setup) Approach

I need an approach to allow delegated admins (i.e., non-Administators) to add members to Public Groups and Collaboration Groups (the GroupMember and CollaborationGroupMember objects). I added a ...
5
votes
1answer
241 views

How to run a batch class for list of string

I have a requirement where I need to process a list of string having hundreds of records in it . For each string I need to have an http callout so I cant run in a normal apex method. For this I am ...
1
vote
1answer
20 views

System.FinalException when doing an Update of a non-final SObject in Batch finish()

I am really confused to see a System.FinalException: Record is read-only in the finish() method of this Apex Batch construct. I have an abstract super class that takes care of the main Apex batch ...