Chilkat Online Tools

lianja / Salesforce Platform APIs / Lookup Table

Back to Collection Items

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

loHttp = createobject("CkHttp")

// 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
//       }
//     ]
//   }
// }

loJson = createobject("CkJsonObject")
loJson.UpdateString("conditions.conditionsList[0].fieldName","IsDeleted")
loJson.UpdateBool("conditions.conditionsList[0].value",.T.)

// Adds the "Authorization: Bearer <access_token>" header.
loHttp.AuthToken = "<access_token>"

loResp = loHttp.PostJson3("https://domain.com/services/data/v{{version}}/connect/business-rules/decision-table/:decisionTableId","application/json",loJson)
if (loHttp.LastMethodSuccess = .F.) then
    ? loHttp.LastErrorText
    release loHttp
    release loJson
    return
endif

loSbResponseBody = createobject("CkStringBuilder")
loResp.GetBodySb(loSbResponseBody)

loJResp = createobject("CkJsonObject")
loJResp.LoadSb(loSbResponseBody)
loJResp.EmitCompact = .F.

? "Response Body:"
? loJResp.Emit()

lnRespStatusCode = loResp.StatusCode
? "Response Status Code = " + str(lnRespStatusCode)
if (lnRespStatusCode >= 400) then
    ? "Response Header:"
    ? loResp.Header
    ? "Failed."
    release loResp
    release loHttp
    release loJson
    release loSbResponseBody
    release loJResp
    return
endif

release loResp

// 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

lcErrorCode = loJResp.StringOf("errorCode")
lcErrorMessage = loJResp.StringOf("errorMessage")
lcOutcomeType = loJResp.StringOf("outcomeType")
llSuccessStatus = loJResp.BoolOf("successStatus")
i = 0
lnCount_i = loJResp.SizeOfArray("outcomeList")
do while i < lnCount_i
    loJResp.I = i
    i = i + 1
enddo


release loHttp
release loJson
release loSbResponseBody
release loJResp

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}"
    }
  ]
}