Back to Collection Items
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @iTmp0 int
-- Important: Do not use nvarchar(max). See the warning about using nvarchar(max).
DECLARE @sTmp0 nvarchar(4000)
-- This example assumes the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
DECLARE @http int
-- Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.Http', @http OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
DECLARE @success int
-- Use this online tool to generate code from sample JSON: Generate Code to Create JSON
-- The following JSON is sent in the request body.
-- {
-- "conditions": {
-- "conditionsList": [
-- {
-- "fieldName": "IsDeleted",
-- "value": true
-- }
-- ]
-- }
-- }
DECLARE @json int
-- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @json OUT
EXEC sp_OAMethod @json, 'UpdateString', @success OUT, 'conditions.conditionsList[0].fieldName', 'IsDeleted'
EXEC sp_OAMethod @json, 'UpdateBool', @success OUT, 'conditions.conditionsList[0].value', 1
-- Adds the "Authorization: Bearer <access_token>" header.
EXEC sp_OASetProperty @http, 'AuthToken', '<access_token>'
DECLARE @resp int
EXEC sp_OAMethod @http, 'PostJson3', @resp OUT, 'https://domain.com/services/data/v{{version}}/connect/business-rules/decision-table/:decisionTableId', 'application/json', @json
EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT
IF @iTmp0 = 0
BEGIN
EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @json
RETURN
END
DECLARE @sbResponseBody int
-- Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.StringBuilder', @sbResponseBody OUT
EXEC sp_OAMethod @resp, 'GetBodySb', @success OUT, @sbResponseBody
DECLARE @jResp int
-- Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
EXEC @hr = sp_OACreate 'Chilkat.JsonObject', @jResp OUT
EXEC sp_OAMethod @jResp, 'LoadSb', @success OUT, @sbResponseBody
EXEC sp_OASetProperty @jResp, 'EmitCompact', 0
PRINT 'Response Body:'
EXEC sp_OAMethod @jResp, 'Emit', @sTmp0 OUT
PRINT @sTmp0
DECLARE @respStatusCode int
EXEC sp_OAGetProperty @resp, 'StatusCode', @respStatusCode OUT
PRINT 'Response Status Code = ' + @respStatusCode
IF @respStatusCode >= 400
BEGIN
PRINT 'Response Header:'
EXEC sp_OAGetProperty @resp, 'Header', @sTmp0 OUT
PRINT @sTmp0
PRINT 'Failed.'
EXEC @hr = sp_OADestroy @resp
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @json
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jResp
RETURN
END
EXEC @hr = sp_OADestroy @resp
-- Sample JSON response:
-- (Sample code for parsing the JSON response is shown below)
-- {
-- "errorCode": null,
-- "errorMessage": null,
-- "outcomeList": [
-- ],
-- "outcomeType": "No Match",
-- "successStatus": true
-- }
-- Sample code for parsing the JSON response...
-- Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
DECLARE @errorCode nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @errorCode OUT, 'errorCode'
DECLARE @errorMessage nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @errorMessage OUT, 'errorMessage'
DECLARE @outcomeType nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @outcomeType OUT, 'outcomeType'
DECLARE @successStatus int
EXEC sp_OAMethod @jResp, 'BoolOf', @successStatus OUT, 'successStatus'
DECLARE @i int
SELECT @i = 0
DECLARE @count_i int
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'outcomeList'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
SELECT @i = @i + 1
END
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @json
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jResp
END
GO
Curl Command
curl -X POST
-H "Authorization: Bearer <access_token>"
-d '{
"conditions": {
"conditionsList": [
{
"fieldName": "IsDeleted",
"value": true
}
]
}
}'
https://domain.com/services/data/v{{version}}/connect/business-rules/decision-table/:decisionTableId
Postman Collection Item JSON
{
"name": "Lookup Table",
"request": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"conditions\": {\n \"conditionsList\": [\n {\n \"fieldName\": \"IsDeleted\",\n \"value\": true\n }\n ]\n }\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{_endpoint}}/services/data/v{{version}}/connect/business-rules/decision-table/:decisionTableId",
"host": [
"{{_endpoint}}"
],
"path": [
"services",
"data",
"v{{version}}",
"connect",
"business-rules",
"decision-table",
":decisionTableId"
],
"variable": [
{
"key": "decisionTableId",
"value": "0lDHo0000008Pnt",
"description": "Decision Table Id"
}
]
},
"description": "# Decision Table (Lookup Table)\n\nPerforms a lookup on a decision table.Resource\n\n```\n/connect/business-rules/decision-table/${decisionTableId}\n\n ```\n\nResource Example\n\n```\nhttps://yourInstance.salesforce.com/services/data/v55.0/connect\n/decision-table/0lDB0000000TNQzMAO\n\n ```\n\nAvailable version\n\n55.0\n\nRequires Chatter\n\nNo\n\nHTTP methods\n\nPOST\n\nRequest body for POST\n\nJSON example\n\n```\n{\n \"conditions\" : {\n \"conditionsList\" : [\n {\n \"fieldName\": \"state__c\",\n \"value\": \"MH\"\n },\n {\n \"fieldName\": \"validity__c\",\n \"value\": 30\n }\n ]\n }\n}\n\n ```\n\nProperties\n\n| Name | Type | Description | Required or Optional | Available Version |\n| --- | --- | --- | --- | --- |\n| conditions | [Decision Table Condition](https://developer.salesforce.com/docs/atlas.en-us.industries_reference.meta/industries_reference/connect_requests_decision_table_condition.htm)\\[\\] | The list of decision table conditions on which the decision table executes and provides outcomes. | Required | 55.0 |\n| datasetLinkName | String | The API name of the dataset link provided as an input for the decision table execution. | Optional | 55.0 |\n\nResponse body for POST\n\n[Decision Table Outcome](https://developer.salesforce.com/docs/atlas.en-us.industries_reference.meta/industries_reference/connect_responses_decision_table_outcome.htm)\n\n# Decision Table Outcome\n\nOutput representation of the decision table execution.JSON example\n\n```\n{\n \"errorCode\" : null,\n \"errorMessage\" : null,\n \"outcomeList\" : [ {\n \"values\" : {\n \"amount__c\" : \"399\",\n \"Name\" : \"MH 005\"\n }\n }, {\n \"values\" : {\n \"amount__c\" : \"499\",\n \"Name\" : \"MH 006\"\n }\n }, {\n \"values\" : {\n \"amount__c\" : \"379\",\n \"Name\" : \"MH 007\"\n }\n }, {\n \"values\" : {\n \"amount__c\" : \"1498\",\n \"Name\" : \"MH 008\"\n }\n }, {\n \"values\" : {\n \"amount__c\" : \"98\",\n \"Name\" : \"MH 009\"\n }\n }, {\n \"values\" : {\n \"amount__c\" : \"251\",\n \"Name\" : \"MH 010\"\n }\n } ],\n \"outcomeType\" : \"Multiple Matches\",\n \"successStatus\" : true\n}\n\n ```\n\n| Property Name | Type | Description | Filter Group and Version | Available Version |\n| --- | --- | --- | --- | --- |\n| errorCode | Integer | The error code if transaction fails for any reason. | Small, 55.0 | 55.0 |\n| errorMessage | String | The error message if transaction fails for any reason. | Small, 55.0 | 55.0 |\n| outcomeList | [Decision Table Outcome Item](https://developer.salesforce.com/docs/atlas.en-us.industries_reference.meta/industries_reference/connect_responses_decision_table_outcome_item.htm)\\[\\] | Outcome list that stores two or more outcomes provided by the decision table. | Small, 55.0 | 55.0 |\n| outcomeType | String | The outcome type after the request is successful. | Small, 55.0 | 55.0 |\n| successStatus | Boolean | Indicates the status of the decision table execution. | Small, 55.0 | 55.0 |"
},
"response": [
{
"name": "Status400-BadRequest",
"originalRequest": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"conditions\": {\n \"conditionsList\": [\n {\n \"fieldName\": \"state__c\",\n \"value\": \"MH\"\n },\n {\n \"fieldName\": \"validity__c\",\n \"value\": 30\n }\n ]\n }\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{_endpoint}}/services/data/v{{version}}/connect/business-rules/decision-table/:decisionTableId",
"host": [
"{{_endpoint}}"
],
"path": [
"services",
"data",
"v{{version}}",
"connect",
"business-rules",
"decision-table",
":decisionTableId"
],
"variable": [
{
"key": "decisionTableId",
"value": "0lIHo000000LFC6MAO",
"description": "Decision Table Id"
}
]
}
},
"status": "Bad Request",
"code": 400,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Date",
"value": "Tue, 19 Sep 2023 12:16:33 GMT"
},
{
"key": "Strict-Transport-Security",
"value": "max-age=63072000; includeSubDomains"
},
{
"key": "X-Content-Type-Options",
"value": "nosniff"
},
{
"key": "X-XSS-Protection",
"value": "1; mode=block"
},
{
"key": "X-Robots-Tag",
"value": "none"
},
{
"key": "Cache-Control",
"value": "no-cache,must-revalidate,max-age=0,no-store,private"
},
{
"key": "Content-Type",
"value": "application/json;charset=UTF-8"
},
{
"key": "Transfer-Encoding",
"value": "chunked"
}
],
"cookie": [
],
"body": "[\n {\n \"errorCode\": \"INVALID_ID_FIELD\",\n \"message\": \"Invalid identifier: 0lIHo000000LFC6MAO\"\n }\n]"
},
{
"name": "Status500-UnknownException",
"originalRequest": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"conditions\": {\n \"conditionsList\": [\n {\n \"fieldName\": \"Comment Count\",\n \"value\": 1\n }\n ]\n }\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{_endpoint}}/services/data/v{{version}}/connect/business-rules/decision-table/:decisionTableId",
"host": [
"{{_endpoint}}"
],
"path": [
"services",
"data",
"v{{version}}",
"connect",
"business-rules",
"decision-table",
":decisionTableId"
],
"variable": [
{
"key": "decisionTableId",
"value": "0lDHo0000008PnjMAE",
"description": "Decision Table Id"
}
]
}
},
"status": "Server Error",
"code": 500,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Date",
"value": "Tue, 19 Sep 2023 12:31:01 GMT"
},
{
"key": "Strict-Transport-Security",
"value": "max-age=63072000; includeSubDomains"
},
{
"key": "X-Content-Type-Options",
"value": "nosniff"
},
{
"key": "X-XSS-Protection",
"value": "1; mode=block"
},
{
"key": "X-Robots-Tag",
"value": "none"
},
{
"key": "Cache-Control",
"value": "no-cache,must-revalidate,max-age=0,no-store,private"
},
{
"key": "Content-Type",
"value": "application/json;charset=UTF-8"
},
{
"key": "Transfer-Encoding",
"value": "chunked"
}
],
"cookie": [
],
"body": "[\n {\n \"message\": \"An unexpected error occurred. Please include this ErrorId if you contact support: 1716762391-743375 (1633993601)\",\n \"errorCode\": \"UNKNOWN_EXCEPTION\"\n }\n]"
},
{
"name": "Status201-Success",
"originalRequest": {
"method": "POST",
"header": [
],
"body": {
"mode": "raw",
"raw": "{\n \"conditions\": {\n \"conditionsList\": [\n {\n \"fieldName\": \"IsDeleted\",\n \"value\": true\n }\n ]\n }\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "{{_endpoint}}/services/data/v{{version}}/connect/business-rules/decision-table/:decisionTableId",
"host": [
"{{_endpoint}}"
],
"path": [
"services",
"data",
"v{{version}}",
"connect",
"business-rules",
"decision-table",
":decisionTableId"
],
"variable": [
{
"key": "decisionTableId",
"value": "0lDHo0000008Pnt",
"description": "Decision Table Id"
}
]
}
},
"status": "Created",
"code": 201,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Date",
"value": "Tue, 19 Sep 2023 13:22:05 GMT"
},
{
"key": "Strict-Transport-Security",
"value": "max-age=63072000; includeSubDomains"
},
{
"key": "X-Content-Type-Options",
"value": "nosniff"
},
{
"key": "X-XSS-Protection",
"value": "1; mode=block"
},
{
"key": "X-Robots-Tag",
"value": "none"
},
{
"key": "Cache-Control",
"value": "no-cache,must-revalidate,max-age=0,no-store,private"
},
{
"key": "Content-Type",
"value": "application/json;charset=UTF-8"
},
{
"key": "Vary",
"value": "Accept-Encoding"
},
{
"key": "Content-Encoding",
"value": "gzip"
},
{
"key": "Transfer-Encoding",
"value": "chunked"
}
],
"cookie": [
],
"body": "{\n \"errorCode\": null,\n \"errorMessage\": null,\n \"outcomeList\": [],\n \"outcomeType\": \"No Match\",\n \"successStatus\": true\n}"
}
]
}