Questions tagged [querylocator]

Represents the record set returned by Database.getQueryLocator and used with Batch Apex.

Filter by
Sorted by
Tagged with
6
votes
2answers
91 views

Mocking Database.QueryLocator in Unit Tests using fflib Apex Mocks

Assume we have some basic AccountSelector class that has different implementations of the selector method. QueryLocator variation is helpful once we need to take advantage of SOQL for loops or to use ...
0
votes
0answers
9 views

How to add conditions in a Batch class when there are n no of clauses

I want to add a clause in the query locator for billingCountry. The commented code runs fine but is there a way to do the same using the NOT IN clause ? I commented line 14,15 and trying to use line ...
0
votes
1answer
23 views

How can I make a SOQL which selects Leads filtered by a Converted Account Field not being true?

We have a requirement, after leads are converted, we are sending data to a partner about them. We have a batch process which will periodically look for newly converted leads, send the data to the ...
0
votes
1answer
271 views

query locator with string query or sobject list

Using the Database.QueryLocator object bypasses the governor limit for the total number of records retrieved by SOQL queries. One could implement one of the following methods to get the QueryLocator: ...
0
votes
2answers
33 views

ERROR:Unexpected token 'Quantity_Available__c'.,expecting a colon, found 'Quantity_Available__c'

How do I get resolved in this? Here's what's been tried so far. global class Batchupdate implements Database.Batchable<sObject> { global Integer recordsProcessed = 0; global List<...
1
vote
0answers
52 views

How can I work with both QueryLocator and List<SObject> in a single batch class (not a single instance)?

I've been working on a chainable batch class. The constructor can take in either a service & query or a service & list of records. In almost all cases, the service/query are passed in. In ...
1
vote
0answers
90 views

INVALID_QUERY_LOCATOR on queryMore on node js

I m getting INVALID_QUERY_LOCATOR error on using queryMore operation using the Enterprise WSDL on node js. Below is the code client.query({queryString:"Select Id,Name FROM Account ORDER BY Name"},...
0
votes
2answers
122 views

Variable not available for a batch query string

I am working on a method that is apart of a batch class to query for Contacts. I'm trying to see if the field "CASL_Compliant_Source__c" is in a keyet that I passed to a makestring method. I keep ...
1
vote
1answer
124 views

OFFSET limit exceeds while implementing pagination for listing of users

Currently, we are trying to populate all users of salesforce in a Visualforce Page with page per limit of 1000 using Database.getQueryLocator (shown below) Database.getQueryLocator('select Id,...
3
votes
2answers
44 views

QueryLocator crashes after casting to Iterable and executing .iterator()

So here is some simple code that does work: Database.QueryLocator ql = Database.getQueryLocator('SELECT Id FROM Account LIMIT 2'); Iterator<SObject> iter = ql.iterator(); Ok. But suppose I ...
0
votes
1answer
24 views

How can I make my <account> variable filterType equal to the first account returned in a StandardSetController Query?

how would this work with a dynamic search page I have a visual force search page and I have used the stadardsetcontroller for pagination. The initial query during page load is working for me. ...
3
votes
2answers
145 views

Where do queries [SELECT …] return QueryLocator instead of List<SObject>?

As a Salesforce Apex developer, it is frequently desirable to have a QueryLocator instead of a List in order to overcome certain governor limits. Moreover, for a variety of reasons, it can be ...
8
votes
3answers
406 views

Is there a typesafe way to get a Database.QueryLocator?

Normally, to select things we use SOQL code like: [ SELECT Id, Blah1__c, Blah2__c, Blah3__c FROM Yada_Yada_Yada__c WHERE Id IN :idSet ]; When we do this, the compiler (and our IDEs) ...
-2
votes
1answer
430 views

Query more than 50000 records in a normal class

I need to query more than 50000 records and store it in a List variable. i know there is a governor limit which prevents it. please let me know if this can be accomplished without going for a batch ...
1
vote
0answers
214 views

Database.querylocater on external object in batch class not returning any rows

I am writing a batch class on external object. Here I am using database.getQuerylocator in start method as the result will contain more thank 50k records. Batch class code: global class <...
0
votes
1answer
96 views

Batch Apex ignores records even without subquery in start()

Basically the querylocator returns about 200000 records at the start, I can see it in logs, also there are not any errors or limits warnings. The size of each job matters because the smaller it is,...
1
vote
1answer
1k views

queryLocator - Use date variable

First off, I am not sure how to properly refer to this type of SOQL query. I am working on a batch process and this is the step where you build the query. What I am having trouble with is putting in ...
0
votes
1answer
597 views

Does an Inner Query in Query Locator count towards row governor limit?

The limit with regards to rows in a query locator is 50 million. Does using an inner query reduce the number of possible rows? For example: Query for Query Locator: SELECT Id, (SELECT Id FROM Orders)...
3
votes
1answer
615 views

Does QueryLocator work with Big Objects?

I am trying to query Big Object records through Database.getQueryLocator method in a Batch class. However, it is throwing an 'Internal Salesforce Error' on the queryLocator line. I tried executing ...
1
vote
1answer
619 views

Batch Apex Chaining Limits?

I'm planning to perform apex batch chaining since I will be working on around 3-4 objects with total records probably crossing 50 millions. I'll be doing something similar to this: How to update 2 ...
0
votes
1answer
1k views

Batch class String query does not allow a set filter

I am working on updating a batch class where I do a query for records and pass them to another class to handle the logic. I want to include a line where the record Id is not in a string set. (I am ...
3
votes
0answers
104 views

Execute Method in Batchable Class does not execute on all records returned in Start method Querylocator

I am seeing a very similar issue to the one discussed in this question, which was due to a bug in Spring '17. The Querylocator returned by the Start method returns 9,989 records, which I can verify ...
1
vote
0answers
126 views

QueryLocator timeout problem?

I have a StandardSetController that I navigate through pages... from a VF page. However, if I let the web page sit for around 15 min or so (not sure about the time) and then try and click the next or ...
0
votes
1answer
142 views

Exception thrown by StandardSetController with Database.getQueryLocator? [closed]

I am using a StandardSetController with Database.getQueryLocator to call my query. I am wondering what can go wrong in this code snippet, i.e. what is the Exception that has a probability of being ...
0
votes
2answers
496 views

Query exception - Unexpected token '{'

I have below query string in an apex batch class that throw error. Can some one please help? Error Unexpected token '{' Query String String query = 'SELECT Call_Duration_Required_abv__c,Id FROM ...
1
vote
2answers
755 views

How to Delete Records in a object except Newly created 1000 Records by using Batch Class?

I have a question, how to delete all records except newly created 1000 records(For Eg: in a Account Object i have 11000 records,in that 1000 records are created in this month, now all 10000 records ...
0
votes
1answer
180 views

Risks of replacing SOQL query with QueryLocator [duplicate]

I used to have this block of code in a widely used method: SObject[] ls = Database.query(q); SObject[] children = new SObject[]{}; for (SObject l : ls) { for (SObject c : l.getSObjects('...
3
votes
2answers
604 views

Inconsistency with error “Aggregate query has too many rows for direct assignment”

I have a Box__c record with 100 Doors__r, 104 Motors__r, and 0 Wheels__r. ISSUE #1 I am getting the error System.QueryException: Aggregate query has too many rows for direct assignment, use FOR ...
0
votes
2answers
3k views

illegal assignmet database.querylocator to list<campaign>

I have a batch class, the return type of start method is 'Database.QueryLocator' and I'm returning the follow: global Database.QueryLocator start(Database.BatchableContext bc) { string ...
1
vote
1answer
811 views

Unexpected token '(' error batch apex

global Database.QueryLocator start(Database.BatchableContext BC) { String query = 'select id,ParticipantName__c,EpisodePoPEndDate__c from BPCIAe__c where id in :CHildParentMap.keyset() OR id in :...
6
votes
1answer
996 views

Batch process order of records in execute

It is more of a conceptual question. I have to write a batch process to do some operation on Leads. It is very important that i first take the oldest lead (created date should be oldest) Let's assume ...
2
votes
1answer
352 views

Argument must implement iterable

I have the following apex batch class: global class BatchUpdateListItem implements Database.Batchable<sObject>, Database.AllowsCallouts { global List<UpdateProduct> update_product {...
5
votes
2answers
627 views

What kind of actions open a query locator

We use a batched approach for read and update CampaignMember records within an external application (Webservice Connector, or WSC SOAP API). The approach can be described like this: Query campaign ...
1
vote
0answers
57 views

Get count of open Query Locators

For debugging porpuses, we would like to get the count of the open "QueryLocators" for an organisation.Is this possible somehow? Thanks
9
votes
1answer
171 views

Read access denied: getQueryLocator(soql) vs. query(soql)

I am attempting to add pagination, and I followed this great article by Jeff Douglas. I am an admin so when I run the page it runs great, I can navigate forwards, back. When I log in as a user my ...
1
vote
1answer
96 views

Compile Error: expecting a right parentheses, found ',' at line 22 column 298

Based on the requirement i have written a batch and schedule class for an email notification to be sent before 90 days. I have used the below query in the code ,where i used to get an email ...
10
votes
2answers
9k views

Exception: QUERY_TIMEOUT Your query request was running for too long

Querying on approx 25 million contacts using the following query in database.getQueryLocator. Used Query Resource Feedback (Link) to get some feedback about query and here are the results. Query - 1: ...
1
vote
1answer
619 views

How to call QueryLocator.iterator() twice

I am using a QueryLocator in my code. In one part of the code I call the .iterator() method to verify that it is not empty. Now I am going through writing a unit test and finding that I am unable to ...
0
votes
1answer
860 views

Count records in QueryLocator?

For counting recording of an sObject I would write ... Select count() from obj; But how do I find out the total records in Database.QueryLocator?