/services/data/vXX.X/jobs/query
Example Post Request
{
"operation": "query",
"query": "SELECT ParentId, FieldHistoryType, Field, Id, NewValue, OldValueFROM FieldHistoryArchive WHERE FieldHistoryType = ‘Account’ AND CreatedDate > LAST_MONTH"
}
Use the Get Results for a Query Job resource.
Example CURL Request
curl --include --request GET \ --header "Authorization: Bearer token" \ --header "Accept: text/csv" \ https://instance.salesforce.com/services/data/vXX.X/jobs/query/750R0000000zxr8IAA/results ?maxRecords=50000
public class QueryBigObjectAndContact implements Database.Batchable<sObject> {
private String key;
public QueryBigObjectAndContact(String keyParam) {
key = keyParam
}
public Iterable<SObject> start(Database.BatchableContext BC) {
return [SELECT Big_Object_Field__c, Account__c FROM Big_Object__b WHERE Big_Object_Primary_Key__c > key LIMIT 50000]
}
public void execute(Database.BatchableContext bc, List<Big_Object__b> bos){
// process the batch of Big Objects and associate them to Accounts
Map<Id, Big_Object__b> accountIdToBigObjectMap = new Map<Id, Big_Object__b>();
for (Big_Object__b bigObject : bos) {
accountIdToBigObjectMap.put(bigObject.Account__c, bigObject);
key = bigObject.Big_Object_Primary_Key__c
}
Map<Id, Account> = new Map<Id, Account>(
[SELECT Id, Name, ... FROM Account WHERE Id IN :accountIdToBigObjectMap.keySet()]
);
for (Id accountId : accountMap.keySet()) {
Big_Object__b bigObject = accountIdToBigObjectMap.get(accountId);
Account account = accountMap.get(accountId);
// perform any actions that integrate the Big Object and Account
}
}
public void finish(Database.BatchableContext bc){
// Daisy chain additional calls using the primary key of the Big Object to get around the 50k governor limit
QueryBigObjectAndContact nextBatch = new QueryBigObjectAndContact(key);
Database.executeBatch(nextBatch);
}
}
public class EventMatchesObject implements Database.Batchable<sObject> {
private String lastEventDate;
public EventMatchesObject(String lastEventDateParam) {
lastEventDate = lastEventDateParam;
}
public Iterable<SObject> start(Database.BatchableContext bc) {
return [SELECT EventDate, EventIdentifier, QueriedEntities, SourceIp, Username, UserAgent FROM ApiEvent WHERE EventDate > lastEventDate LIMIT 50000]
}
public void execute(Database.BatchableContext bc, List<ApiEvent> events){
// Process this list of entities if a certain attribute matches
for (ApiEvent event: events) {
String objectString = 'Patent__c';
String eventIdentifier = event.EventIdentifier;
if (eventIdentifier.contains(objectString) {
// Perform actions on the event that contains 'Patent__c'
}
lastEventDate = format(event.EventDate);
}
}
public void finish(Database.BatchableContext bc){
// Daisy chain additional calls using EventDate or other filter fields to get around the 50k governor limit
EventMatchesObject nextBatch = new EventMatchesObject(lastEventDate);
Database.executeBatch(nextBatch);
}
}
public class CountBigObjects implements Database.Batchable<sObject> {
private Integer recordsCounted;
private String key;
public CountBigObjects(Integer recordsCountedParam, String keyParam) {
recordsCounted = recordsCountedParam
key = keyParam
}
public Iterable<SObject> start(Database.BatchableContext bc) {
return [SELECT Custom_Field__c FROM Big_Object__b LIMIT 25000]
}
public void execute(Database.BatchableContext bc, List<Big_Object__b> bos){
// process the batch of Big Objects and associate them to Accounts
Map<Id, Big_Object__b> accountIdToBigObjectMap = new Map<Id, Big_Object__b>();
for (Big_Object__b bigObject : bos) {
accountIdToBigObjectMap.put(bigObject.Account__c, bigObject);
}
Map<Id, Account> accountMap = new Map<Id, Account>(
[SELECT Id, Name, ... FROM Account WHERE Id IN :accountIdToBigObjectMap.keySet()]
);
for (Id accountId : accountMap.keySet()) {
Big_Object__b bigObject = accountIdToBigObjectMap.get(accountId);
Account account = accountMap.get(accountId);
// perform any actions that integrate the Big Object and Account
}
}
public void finish(Database.BatchableContext bc) {
// Daisy chain additional calls using the primary key of the Big Object to get around the 50k governor limit
CountBigObjects nextBatch = new CountBigObjects(recordsCounted, key);
Database.executeBatch(nextBatch);
}
}
If you have more questions, refer to Salesforce Help. To read about the Salesforce approach to retiring products and features, read our Product & Feature Retirement Philosophy.
000394892

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.