Newer Version Available

This content describes an older version of this product. View Latest

Async Query Input

Create an Async SOQL query job.
Root XML tag
<asyncQueryInput>
JSON example
1{ 
2   "query": "SELECT firstField__c, secondField__c FROM SourceObject__c",  
3   
4   "operation": "insert",
5   
6   "targetObject": "TargetObject__c", 
7        
8   "targetFieldMap": {"firstField__c":"firstFieldTarget__c",
9                      "secondField__c":"secondFieldTarget__c"
10                      },
11   "targetValueMap": {"$JOB_ID":"BackgroundOperationLookup__c",
12                      "Copy fields from source to target":"BackgroundOperationDescription__c"
13                     }
14}
Properties
Name Type Description Required or Optional Available Version
query String Specifies the parameters for the SOQL query you want to execute. Required 35.0
operation String Specify whether the query is an insert or upsert. If the record doesn’t exist, an upsert behaves like an insert.

Upsert is not supported for big objects

Note

Optional 39.0
targetObject String A standard object, custom object, external object, or big object into which to insert the results of the query. Required 35.0
targetFieldMap Map<String, String> Defines how to map the fields in the query result to the fields in the target object.

When defining the targetFieldMap parameter, make sure that the field type mappings are consistent. If the source and target fields don’t match, these considerations apply.

  • Any source field can be mapped onto a target text field.
  • If the source and target fields are both numerical, the target field must have the same or greater number of decimal places than the source field. If not, the request fails. This behavior is to ensure that no data is lost in the conversion.
  • If a field in the query result is mapped more than once, even if mapped to different fields in the target object, only the last mapping is used.

Note

Required 35.0
targetValueMap Map<String, String> Defines how to map static strings to fields in the target object. Any field or alias can be used as the TargetValueMap value in the SELECT clause of a query.

You can map the special value, $JOB_ID, to a field in the target object. The target field must be a lookup to the Background Operation standard object. In this case, the ID of the Background Operation object representing the Async SOQL query is inserted. If the target field is a text field, it must be at least 15–18 characters long.

You can also include any field or alias in the SELECT clause of the TargetValueMap. They can be combined together to concatenate a value to be used.

Optional 37.0
targetExternalIdField String The ID of the target sObject. Required for upsert operations. Optional 39.0