Getting results back from batch query job
See original GitHub issueI have something like this, where I want to send a query as a bulk batch job.
const job = conn.bulk.createJob('Account', 'query');
var batch = job.createBatch();
let endBatch;
batch.execute(theQuery);
batch.on('queue', batchInfo => {
console.log('in queue');
endBatch = conn.bulk.job(batchInfo.jobId).batch(batchInfo.batchId);
endBatch.poll(500, 20000);
endBatch.on('response', response => {
console.log('response', response);
endBatch.check().then(yo => {
console.log('check', yo);
});
endBatch
.retrieve()
.then(results => {
console.log('end', results);
})
.catch(handleError);
});
});
However, all I ever get back from the retrieve()
is something like this, without the actual results themselves.
end [ { id: '75261000008FPXW',
batchId: '7516100000GnBSwAAN',
jobId: '7506100000CtuBwAAJ' } ]
My check also shows that everything has completed, but I never get the results back:
check { '$': { xmlns: 'http://www.force.com/2009/06/asyncapi/dataload' },
id: '7516100000GnBSwAAN',
jobId: '7506100000CtuBwAAJ',
state: 'Completed',
createdDate: '2018-08-01T18:36:12.000Z',
systemModstamp: '2018-08-01T18:36:12.000Z',
numberRecordsProcessed: '2',
numberRecordsFailed: '0',
totalProcessingTime: '0',
apiActiveProcessingTime: '0',
apexProcessingTime: '0' }
Looking at the actual code in api_bulk.js
, it seems like results are never actually getting returned. - Am I missing something here? Is there another event I should be listening for?
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (1 by maintainers)
Top Results From Across the Web
Run interactive and batch query jobs | BigQuery - Google Cloud
This document shows you how to run two types of query jobs in BigQuery: Interactive query jobs, which are jobs that BigQuery runs...
Read more >Get Batch Results - Bulk API - Salesforce Developers
Get results of a batch that completed processing by sending a GET request to this URI. ... enter Bulk Data Load Jobs ,...
Read more >Get Job Results - Knowledge Center - Zuora
Use Get Results Files to download the query results file. The query results file is formatted as requested in the batch job.
Read more >Can There be Multiple Result IDs for a Query Operation Result?
To get the actual results, we have to call the URL (sfdc)/services/async/48.0/job/jobId/batch/batchId/result/resultId with the result ID in the ...
Read more >How to fetch the result of Salesforce Batch Job with the result ...
When using Batch Result there is no option to handle CSV response. With the Batch Result Stream operation there is an option to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Does anyone have a recommendation on how to retrieve the results when working in typescript?
@supermarioim Here’s how we’re doing large fetches of Salesforce tables via Bulk API, if this helps. We decided to just handle the RecordStream ourselves to have finer control of what’s happening, see the comments.
We’re still debugging some occasional Salesforce polling timeouts that seem customer-specific (i.e. maybe certain Salesforce instances have a ton of records, the Bulk API queue is backed up, etc.). We might resort to getting fewer records via the REST API in that case.
Hopefully this helps!
Usage would be something like:
Note: During these requests, an error with
error.name === 'invalid_grant'
maybe be triggered, so watch out for that! We wrap our calls to getSalesforceRecords with some error handling that catches invalid_grant and triggers our apps token refresh logic.