Skip to main content

QuerySalesforceObject

Description

Retrieves records from a Salesforce sObject. Users can add arbitrary filter conditions by setting the 'Custom WHERE Condition' property. The processor can also run a custom query, although record processing is not supported in that case. Supports incremental retrieval: users can define a field in the 'Age Field' property that will be used to determine when the record was created. When this property is set the processor will retrieve new records. Incremental loading and record-based processing are only supported in property-based queries. It's also possible to define an initial cutoff value for the age, filtering out all older records even for the first run. In case of 'Property Based Query' this processor should run on the Primary Node only. FlowFile attribute 'record.count' indicates how many records were retrieved and written to the output. The processor can accept an optional input FlowFile and reference the FlowFile attributes in the query. When 'Include Deleted Records' is true, the processor will include deleted records (soft-deletes) in the results by using the 'queryAll' API. The 'IsDeleted' field will be automatically included in the results when querying deleted records.

Tags

query, salesforce, sobject, soql

Properties

In the list below required Properties are shown with an asterisk (*). Other properties are considered optional. The table also indicates any default values, and whether a property supports the NiFi Expression Language.

Display NameAPI NameDefault ValueAllowable ValuesDescription
Salesforce Instance URL *salesforce-urlThe URL of the Salesforce instance including the domain without additional path information, such as https://MyDomainName.my.salesforce.com

Supports Expression Language, using Environment variables.
API Version *salesforce-api-version54.0The version number of the Salesforce REST API appended to the URL after the services/data path. See Salesforce documentation for supported versions

Supports Expression Language, using Environment variables.
Query Type *query-typeProperty Based Query
  • Property Based Query
  • Custom Query
Choose to provide the query by parameters or a full custom query.
Custom SOQL Query *custom-soql-querySpecify the SOQL query to run.

Supports Expression Language, using FlowFile attributes and Environment variables.

This property is only considered if:
  • the property Query Type has a value of custom-query
sObject Name *sobject-nameThe Salesforce sObject to be queried

Supports Expression Language, using Environment variables.

This property is only considered if:
  • the property Query Type has a value of property-based-query
Field Namesfield-namesComma-separated list of field names requested from the sObject to be queried. When this field is left empty, all fields are queried.

Supports Expression Language, using Environment variables.

This property is only considered if:
  • the property Query Type has a value of property-based-query
Record Writer *record-writerController Service:
RecordSetWriterFactory

Implementations:
AvroRecordSetWriter
CSVRecordSetWriter
FreeFormTextRecordSetWriter
JsonRecordSetWriter
RecordSetWriterLookup
ScriptedRecordSetWriter
XMLRecordSetWriter
Service used for writing records returned from the Salesforce REST API

This property is only considered if:
  • the property Query Type has a value of property-based-query
Age Fieldage-fieldThe name of a TIMESTAMP field that will be used to filter records using a bounded time window.The processor will return only those records with a timestamp value newer than the timestamp recorded after the last processor run.

Supports Expression Language, using Environment variables.

This property is only considered if:
  • the property Query Type has a value of property-based-query
Initial Age Start Timeinitial-age-filterThis property specifies the start time that the processor applies when running the first query.

Supports Expression Language, using Environment variables.

This property is only considered if:
  • the property Age Field has a value specified
  • the property Query Type has a value of property-based-query
Age Delayage-delayThe ending timestamp of the time window will be adjusted earlier by the amount configured in this property. For example, with a property value of 10 seconds, an ending timestamp of 12:30:45 would be changed to 12:30:35.

Supports Expression Language, using Environment variables.

This property is only considered if:
  • the property Age Field has a value specified
  • the property Query Type has a value of property-based-query
Custom WHERE Conditioncustom-where-conditionA custom expression to be added in the WHERE clause of the query

Supports Expression Language, using FlowFile attributes and Environment variables.

This property is only considered if:
  • the property Query Type has a value of property-based-query
Include Deleted Records *include-deleted-recordsfalse
  • true
  • false
If true, the processor will include deleted records (IsDeleted = true) in the query results. When enabled, the processor will use the 'queryAll' API.

This property is only considered if:
  • the property Query Type has a value of property-based-query
Read Timeout *read-timeout15 sMaximum time allowed for reading a response from the Salesforce REST API

Supports Expression Language, using Environment variables.
Create Zero Record FlowFiles *create-zero-record-filesfalse
  • true
  • false
Specifies whether or not to create a FlowFile when the Salesforce REST API does not return any records

This property is only considered if:
  • the property Query Type has a value of property-based-query
OAuth2 Access Token Provider *oauth2-access-token-providerController Service:
OAuth2AccessTokenProvider

Implementations:
StandardOauth2AccessTokenProvider
Service providing OAuth2 Access Tokens for authenticating using the HTTP Authorization Header

Dynamic Properties

This component does not support dynamic properties.

Relationships

NameDescription
failureThe input flowfile gets sent to this relationship when the query fails.
originalThe input flowfile gets sent to this relationship when the query succeeds.
successFor FlowFiles created as a result of a successful query.

Reads Attributes

This processor does not read attributes.

Writes Attributes

NameDescription
mime.typeSets the mime.type attribute to the MIME Type specified by the Record Writer.
record.countSets the number of records in the FlowFile.
total.record.countSets the total number of records in the FlowFile.

State Management

ScopeDescription
CLUSTERWhen 'Age Field' is set, after performing a query the time of execution is stored. Subsequent queries will be augmented with an additional condition so that only records that are newer than the stored execution time (adjusted with the optional value of 'Age Delay') will be retrieved. State is stored across the cluster so that this Processor can be run on Primary Node only and if a new Primary Node is selected, the new node can pick up where the previous node left off, without duplicating the data.

Restricted

This component is not restricted.

Input Requirement

This component allows an incoming relationship.

System Resource Considerations

This component does not specify system resource considerations.

See Also

PutSalesforceObject