In Salesforce, the Approval Submission object represents the record created when a business process or orchestration is submitted for approval. However, unlike standard sObjects, some of its key fields — such as Status — are read-only in Apex.

This restriction means you cannot directly update or cancel an approval submission record through Apex code. To handle such cancellations programmatically, Salesforce provides a Standard REST API action called
cancelApprovalSubmission.

This blog walks through why and how to use this API, and how you can automate cancellation from within Salesforce using an Invocable Action.

Why Cancel via API and Not Apex?

When an approval submission is created, it’s tightly coupled with its corresponding Orchestration Run.
However:

  • Canceling an Approval Submission via the Standard REST API also cancels the associated Orchestration Run automatically ✅
  • Canceling only the Orchestration Run does not cancel the Approval Submission

Hence, the recommended and most reliable approach is to cancel the approval submission record using the standard Salesforce REST API.

API Endpoint Details

PropertyValue
Endpoint/services/data/v65.0/actions/standard/cancelApprovalSubmission
HTTP MethodPOST
FormatsJSON, XML
AuthenticationOAuth 2.0 (Bearer Token)

Request and Response Format

Sample Request

{
  "inputs": [
    {
      "approvalSubmissionId": "9iPxx00000001lhEBA",
      "comments": "Cancellation triggered by case closure."
    }
  ]
}

Sample Successful Response

{
  "actionName": "cancelApprovalSubmission",
  "errors": null,
  "invocationId": null,
  "isSuccess": true,
  "outcome": null,
  "outputValues": null,
  "sortOrder": -1,
  "version": 1
}

Sample Failure Response

{
  "actionName": "cancelApprovalSubmission",
  "errors": [
    {
      "statusCode": "INVALID_RECORD_ATTRIBUTE_VALUE",
      "message": "We couldn't complete this action because the record is already in Canceled status.",
      "fields": []
    }
  ],
  "isSuccess": false
}

Authentication Setup

This API cannot be called using a simple SessionId from Apex or Flow.
To authenticate properly, you can use one of the following approaches:

Option 1: Connected App + Auth Provider + Named Credential
Option 2: VF Page Session Approach

Refer to the Authenticate Salesforce REST APIs for Authentication steps.

Invocable Action

You can encapsulate the API call within an Invocable Apex Action, allowing it to be triggered seamlessly from a Flow.
Refer to the Invocable Action blog for detailed steps on how to create one.

Example Use Case:
When a Case record’s Status is updated to Closed, a Record-Triggered Flow invokes this Apex action to automatically cancel any related Approval Submissions.

This makes the automation completely click-driven while keeping the backend API-driven.

Sample Apex Implementation

Below is a simple Apex implementation:

public with sharing class CancelApprovalSubmissionAPI {
    
    public class RequestInput {
        public String approvalSubmissionId;
        public String comments;
    }

    public class RequestWrapper {
        public List<RequestInput> inputs;
    }

    public class Error {
        public String statusCode;
        public String message;
        public List<String> fields;
    }

    public class Response {
        public String actionName;
        public List<Error> errors;
        public Boolean isSuccess;
    }

    @AuraEnabled
    public static Response cancelApproval(String approvalSubmissionId, String comments) {
        HttpRequest req = new HttpRequest();
        req.setEndpoint('callout:CMN_SelfSalesforce_NC/services/data/v65.0/actions/standard/cancelApprovalSubmission');
        req.setMethod('POST');
        req.setHeader('Content-Type', 'application/json');

        RequestInput input = new RequestInput();
        input.approvalSubmissionId = approvalSubmissionId;
        input.comments = comments;

        RequestWrapper wrapper = new RequestWrapper();
        wrapper.inputs = new List<RequestInput>{input};

        req.setBody(JSON.serialize(wrapper));

        Http http = new Http();
        HttpResponse res = http.send(req);

        return (Response) JSON.deserialize(res.getBody(), Response.class);
    }
}

Automating the cancellation of approval submissions ensures smoother governance and better alignment with complex case management or approval flows.
By combining Salesforce’s Standard REST API with Named Credentials and Flows, you can build a robust, secure, and no-maintenance automation layer — without custom integrations.

Resources

Cancel Approval Submission Action

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *