Questions tagged [querylocator]
Represents the record set returned by Database.getQueryLocator and used with Batch Apex.
50
questions
0
votes
1
answer
27
views
Database.QueryLocator mocking during unit test
Let's say we have
public DataBase.QueryLocator start(Database.BatchableContext bc) {
if(this.sources.size() == 0) return Database.getQueryLocator('SELECT id FROM Account WHERE id = null');
Id ...
1
vote
1
answer
131
views
Apex Batch QueryLocator : SOQL statements cannot query aggregate relationships more than 1 level away from the root entity object
I am writing a Batch Apex job that will process the Account records. In my SOQL query, I also want to query the child records of the Account SObject. The child records are for the immediate child ...
0
votes
1
answer
176
views
How do I check if LWC component has a public method
I have a form with inputs being either standard LWC inputs or custom lookups.
I want to validate the form and report error back to the user.
I use this.template.querySelector to get the inputs and ...
-4
votes
1
answer
250
views
How to setup query on query locator [closed]
I'm trying to setup a batch and i'm using query locator to query the records and i'm custom meta to store my query i'm facing the issues while running the job.
I'm getting this exception:
System....
2
votes
2
answers
561
views
Batch Class Error: Start did not return a valid iterable object
I have a simple piece of batch code that iterates over all Location__c records that don't already have Folders. It then calls a method to create the missing folders.
public with sharing class ...
-1
votes
1
answer
134
views
Inner SOQL query API Call
I am using a SOQL query that uses an inner query that returns the parent details along with all child details as one json record as API response. I would like to know how can nexturl be used when a ...
-1
votes
2
answers
110
views
squery not fetching the values in the batch class [closed]
need some help for the batch class as i am not able to print the sQuery values in the batch class, not sure what is the correct way to do this one.
kindly some one help me for the correct sQuery in ...
0
votes
2
answers
75
views
page locator changed after winter 22 upgrade
I am seeing that page locator changed on create new record pages, possibly after winter'22 Salesforce release. Can this be possible.
For example,
old locator was available as,
//div[contains(@class,'...
0
votes
1
answer
6k
views
REQUEST_RUNNING_TOO_LONG :Your request was running for too long, and has been stopped
I have created a Batch which is supposed to pull Completed tasks and Reopen them. It's a simple implementation (code attached), but what i observe is the Query is taking too long and ultimately aborts ...
0
votes
1
answer
296
views
Does it make sense to use ORDER BY clause when it comes to batch `start()` method
Could anyone explain more what
Batches of records tend to execute in the order in which they’re received from the start method. However, the order in which batches of records execute depends on ...
2
votes
1
answer
81
views
Query_more behaviour when the data is modified during execution
I have a pretty slow operation to apply to a large number of records (1.5M+).
All these records have not be modified for more than six months.
To get these records I use api calls query() then ...
1
vote
1
answer
660
views
How to conditionally control the execution of execute() method from the start() method of a batch class
I'm making a call out to get an auth token in the start() method of my batch class (I'm implementing the stateful interface and using a class variable to save this token for the entire batch ...
9
votes
3
answers
3k
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
1
answer
1k
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
1
answer
5k
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
2
answers
61
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<...
2
votes
0
answers
829
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
0
answers
396
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
2
answers
1k
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
1
answer
905
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,...
5
votes
3
answers
207
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
1
answer
29
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. ...
4
votes
2
answers
303
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
3
answers
1k
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
1
answer
2k
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
0
answers
715
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
1
answer
142
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
1
answer
2k
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 ...
1
vote
1
answer
3k
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)...
4
votes
1
answer
1k
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
1
answer
1k
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
1
answer
2k
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
0
answers
113
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
0
answers
188
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
1
answer
254
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
2
answers
1k
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
2
answers
2k
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
1
answer
214
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
2
answers
2k
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
2
answers
7k
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
1
answer
1k
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
1
answer
2k
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
1
answer
440
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
2
answers
1k
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
0
answers
77
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
10
votes
1
answer
310
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
1
answer
315
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
2
answers
20k
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
1
answer
1k
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
1
answer
1k
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?