Pipeline Operation: Execute Apex

Run anonymous Apex code directly within a Revvy pipeline to perform custom Salesforce logic, automate data operations, or trigger post-deployment activities

The Execute Apex operation allows you to run Apex code anonymously in a connected Salesforce organization. It’s useful for performing automated actions such as data initialization, configuration updates, or triggering validation logic after deployment.

This operation executes the code snippet provided in the step configuration and logs the compile and runtime results for review.

Configuration Options

When creating or editing an Execute Apex step, configure the following:

  • Name: Step name to identify the action (e.g., Execute Anonymous).

  • Operation: Execute Apex.

  • Target Organization: Choose the Salesforce org where the code should run (e.g., TargetSandbox).

  • Code: Enter the Apex code to execute (e.g.,

    System.debug('Hello from Execute Anonymous!');)

  • Next Step (On Pass / On Fail): Define what the pipeline should do after execution — Stop or Continue.

Creating an Execute Apex Step

  1. Go to Pipelines → Create or Edit an existing pipeline.

  2. Click the + icon between Start and Stop.

  3. In the configuration panel, enter:

    • Name: Execute Anonymous

    • Operation: Execute Apex

    • Target Organization: TargetSandbox

    • Code: System.debug('Hello from Execute Anonymous!');

    • On Pass / On Fail: Stop

  4. Click Add to save.

Running a Pipeline

  1. Click Run Pipeline from the top-right corner.

  2. The pipeline executes and sends the provided Apex code to the target org.

  3. Status updates in real time:

    • In Progress — Code execution started.

    • Completed — Code executed successfully.

    • Exception — Execution failed due to syntax or runtime errors.

Viewing Results

After execution, go to Code → Branch → Activities → Pipelines.

Each job lists key information:

  • Type: Execute Apex

  • Status: Completed / Exception / In Progress

  • Duration: Total runtime

  • Created By: User who initiated the job

Click the pipeline name (e.g., Validate Pipeline) to open detailed job results.

Logs and Execution Output

Select the Execute Anonymous step in the pipeline results view to open execution logs.

Logs display real-time Apex compilation and runtime messages returned from Salesforce.

Example log:

[Oct 10, 2025 3:50 PM] [info] Apex execution started  
[Oct 10, 2025 3:50 PM] [info] Apex execution result:  
[Oct 10, 2025 3:50 PM] [info] Compiled: true  
[Oct 10, 2025 3:50 PM] [info] Success: true  
[Oct 10, 2025 3:50 PM] [info] Logs: 64.0  
APEX_CODE,DEBUG;Execute Anonymous:  
System.debug('Hello from Execute Anonymous!');  
[USER_INFO] Execution completed successfully

Troubleshooting

  • Compilation Errors: Check the Apex code syntax — ensure semicolons and variable declarations are correct.

  • Authorization Issues: Verify the connected org has appropriate permissions to execute anonymous code.

  • Timeouts: Long-running Apex operations may exceed execution time limits. Optimize logic or break into smaller steps.

  • No Output: Add System.debug() statements in the code to log key values or operations.

Best Practices

  • Use Execute Apex to automate configuration tasks after metadata deployment.

  • Keep code snippets simple — avoid DML or callouts unless required.

  • Always test your code in a sandbox before running in production.

  • Combine Execute Apex with Manual Step for review or approval before execution.

  • Monitor logs under Activities → Pipelines to confirm successful runs.

Last updated

Was this helpful?