Apex API

Use pushtopics.ExecutionService to start Batch executions of Executables and Pipelines from Apex. You can run an Executable by its configured criteria or specific record IDs, and run a Pipeline with optional additional Retrieve parameters.

To start executions from an external system or another org, use the REST API instead.

executeExecutableByApiName(String apiName)

Starts a Batch execution of the specified Executable using its configured Retrieve Criteria.

Parameter

Parameter Type Description
apiNameStringThe API Name of the Executable to run.

Returns

A pushtopics__Execution__c record representing the execution created for this request.

Example

Run the Account.RollupSummaries Executable:

apex
pushtopics__Execution__c execution =
    pushtopics.ExecutionService.executeExecutableByApiName(
        'Account.RollupSummaries'
    );

executeExecutableByApiName(String apiName, List<Id> recordIds)

Starts a Batch execution of the specified Executable, using the provided record IDs in addition to the Executable's configured Retrieve Criteria.

Parameter

Parameter Type Description
apiNameStringThe API Name of the Executable to run.
recordIdsList<Id>The IDs of the source records to include in the retrieval.

Returns

A pushtopics__Execution__c record representing the execution created for this request.

Example

Run Account.RollupSummaries for a specified Account:

apex
pushtopics__Execution__c execution =
    pushtopics.ExecutionService.executeExecutableByApiName(
        'Account.RollupSummaries',
        new List<Id>{ '001000000000001AAA' }
    );

executePipelineByApiName(String pipelineApiName)

Executes the Batch Executables in the specified Pipeline and returns the created Pipeline Execution record. Use this overload when no additional Retrieve parameters are needed.

Parameter

Parameter Type Description
pipelineApiNameStringThe API Name of the Pipeline to run.

Returns

A pushtopics__PipelineExecution__c record representing the Pipeline Execution created for this request.

Example

Start a Batch run of the Executables in Opportunity.Batches:

apex
pushtopics__PipelineExecution__c pipelineExecution =
    pushtopics.ExecutionService.executePipelineByApiName(
        'Opportunity.Batches'
    );

executePipelineByApiName(String pipelineApiName, Object additionalRetrieveParameters)

Executes the Batch Executables in the specified Pipeline with additional Retrieve parameters, such as filter conditions and ORDER BY clauses, applied to their configured source retrieval queries.

Parameter

Parameter Type Description
pipelineApiNameStringThe API Name of the Pipeline to run.
additionalRetrieveParametersString | Map<String, Object>Additional Retrieve parameters for the Pipeline's Batch Executables. Use a String to apply the same parameters to all Batch Executables, or a Map to specify parameters for individual Executables.

Returns

A pushtopics__PipelineExecution__c record representing the Pipeline Execution created for this request.

Example

Run Opportunity.Batches with the same additional Retrieve parameters for all Batch Executables:

apex
pushtopics__PipelineExecution__c pipelineExecution =
    pushtopics.ExecutionService.executePipelineByApiName(
        'Opportunity.Batches',
        'CreatedDate = LAST_N_DAYS:30 ORDER BY CreatedDate DESC'
    );

Run Opportunity.Batches with separate additional Retrieve Filters for two Executables:

apex
pushtopics__PipelineExecution__c pipelineExecution =
    pushtopics.ExecutionService.executePipelineByApiName(
        'Opportunity.Batches',
        new Map<String, Object>{
            'Opportunity.CloseStale' =>
                'CloseDate < LAST_N_DAYS:90',
            'Account.RollupSummaries' =>
                'Type = \'Customer\''
        }
    );