Generate Quote Document API
Service Router
CPQ API Quickstart Guide
Disable CPQ Triggers in Apex
Approval API
Reject Approval API
Salesforce CPQ Plugins
Previous Versions
Call the Advanced Approvals reject approval service from an outside source.
| Required Editions |
|---|
| Available in: Advanced Approvals Spring ‘21 and later |
Invoke the approval API using the following service router call, replacing class with your class name and method with your method name.
ServiceRouter?saver=AA.{class}.{method}
Use the following endpoint, replacing server with your server address.
<server>/services/apexrest/SBAA/ServiceRouter
The approval service accepts the following parameters.
| Parameter | Required | Description |
|---|---|---|
approvalID | Required | ID of the approval record in Salesforce. |
comments | Optional | Comments about the approval. |
Sample Request
Include a saver in the request body model. When you send the approval request, the CPQ service router evaluates the model and finds the saver attribute. It then takes the value of the saver attribute - in this case, Reject - and maps that to the corresponding Advanced Approvals Apex class.
Content type: application/json
Authorization: Bearer [Access token or session ID]
1model:{
2approvalId: “a1Sx000000000gF”,
3comments: “ok then"},
4saver: "SBAA.ApprovalRestApiProvider.Reject"
5}Sample CURL Request
1curl -X POST https://velocity-efficiency-9575-dev-ed.develop.my.salesforce.com/services/apexrest/sbaa/ServiceRouter
2-H 'Authorization: Bearer
300D1h0000008LeO!ARIAQL4Aj0OVYWIIcROefe8SYP1579EMEAnXXXXXXXXXXXXXX'
4-H 'Content-Type: application/json'
5-d '{"model":"{\"approvalId\":\"a061h000002pIlTAAU\",\"comments\”:\”Rejected\”}”,”saver":"SBAA.ApprovalRestApiProvider.Reject"}'This example shows a basic Javscript function for calling the Reject Service API from Google Sheets.
1function reject() {
2 var sheet = SpreadsheetApp.getActiveSheet();
3 var data = sheet.getDataRange().getValues();
4 // Make a POST request with a JSON payload.
5 var model = {
6 "approvalId": data[1][0],
7 "comments": data[1][1]
8 };
9 var data = {
10 'saver': 'SBAA.ApprovalRestApiProvider.Reject',
11 'model': JSON.stringify(model)
12 };
13 var header = {
14 'authorization' : 'Bearer 00Dx0000000IiSD!ARoAQAiD7e.IshlpUqRUQo3Fu6MSox3y1ToMNdEl8MqXXXXXXXXXXXX'
15 };
16 var options = {
17 'method' : 'post',
18 'contentType': 'application/json',
19 'headers': header,
20 'muteHttpExceptions': false,
21 // Convert the JavaScript object to a JSON string.
22 'payload' : JSON.stringify(data)
23 };
24 var response = UrlFetchApp.fetch('server/services/apexrest/SBAA/ServiceRouter', options);
25 var responseText = response.getContentText();