Chilkat Online Tools

unicodeCpp / Salesforce Platform APIs / Create Table

Back to Collection Items

#include <CkHttpW.h>
#include <CkJsonObjectW.h>
#include <CkHttpResponseW.h>
#include <CkStringBuilderW.h>

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

    CkHttpW http;
    bool success;

    // Use this online tool to generate code from sample JSON: Generate Code to Create JSON

    // The following JSON is sent in the request body.

    // {
    //   "setupName": "Product Qualificiation eligibility",
    //   "fullName": "ProductQualificationEligibility",
    //   "description": "Eligiblity of Products using Qualification Rules",
    //   "sourceObject": "AccountFeed",
    //   "status": "Draft",
    //   "conditionType": "Any",
    //   "conditionCriteria": "1 OR 2 OR 3",
    //   "parameters": [
    //     {
    //       "fieldName": "IsDeleted",
    //       "usage": "INPUT",
    //       "operator": "Equals",
    //       "sequence": "1"
    //     },
    //     {
    //       "fieldName": "Id",
    //       "usage": "INPUT",
    //       "operator": "Equals",
    //       "sequence": "2"
    //     },
    //     {
    //       "fieldName": "Title",
    //       "usage": "INPUT",
    //       "operator": "Equals",
    //       "sequence": "3"
    //     },
    //     {
    //       "fieldName": "CreatedById",
    //       "usage": "OUTPUT"
    //     }
    //   ]
    // }

    CkJsonObjectW json;
    json.UpdateString(L"setupName",L"Product Qualificiation eligibility");
    json.UpdateString(L"fullName",L"ProductQualificationEligibility");
    json.UpdateString(L"description",L"Eligiblity of Products using Qualification Rules");
    json.UpdateString(L"sourceObject",L"AccountFeed");
    json.UpdateString(L"status",L"Draft");
    json.UpdateString(L"conditionType",L"Any");
    json.UpdateString(L"conditionCriteria",L"1 OR 2 OR 3");
    json.UpdateString(L"parameters[0].fieldName",L"IsDeleted");
    json.UpdateString(L"parameters[0].usage",L"INPUT");
    json.UpdateString(L"parameters[0].operator",L"Equals");
    json.UpdateString(L"parameters[0].sequence",L"1");
    json.UpdateString(L"parameters[1].fieldName",L"Id");
    json.UpdateString(L"parameters[1].usage",L"INPUT");
    json.UpdateString(L"parameters[1].operator",L"Equals");
    json.UpdateString(L"parameters[1].sequence",L"2");
    json.UpdateString(L"parameters[2].fieldName",L"Title");
    json.UpdateString(L"parameters[2].usage",L"INPUT");
    json.UpdateString(L"parameters[2].operator",L"Equals");
    json.UpdateString(L"parameters[2].sequence",L"3");
    json.UpdateString(L"parameters[3].fieldName",L"CreatedById");
    json.UpdateString(L"parameters[3].usage",L"OUTPUT");

    // Adds the "Authorization: Bearer <access_token>" header.
    http.put_AuthToken(L"<access_token>");

    CkHttpResponseW *resp = http.PostJson3(L"https://domain.com/services/data/v{{version}}/connect/business-rules/decision-table/definitions",L"application/json",json);
    if (http.get_LastMethodSuccess() == false) {
        wprintf(L"%s\n",http.lastErrorText());
        return;
    }

    CkStringBuilderW sbResponseBody;
    resp->GetBodySb(sbResponseBody);

    CkJsonObjectW jResp;
    jResp.LoadSb(sbResponseBody);
    jResp.put_EmitCompact(false);

    wprintf(L"Response Body:\n");
    wprintf(L"%s\n",jResp.emit());

    int respStatusCode = resp->get_StatusCode();
    wprintf(L"Response Status Code = %d\n",respStatusCode);
    if (respStatusCode >= 400) {
        wprintf(L"Response Header:\n");
        wprintf(L"%s\n",resp->header());
        wprintf(L"Failed.\n");
        delete resp;
        return;
    }

    delete resp;

    // Sample JSON response:
    // (Sample code for parsing the JSON response is shown below)

    // {
    //   "code": "200",
    //   "decisionTable": {
    //     "id": "0lDHo0000008Pnt",
    //     "parameters": [
    //     ],
    //     "sourceCriteria": [
    //     ]
    //   },
    //   "isSuccess": true,
    //   "message": ""
    // }

    // Sample code for parsing the JSON response...
    // Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code

    // Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.

    const wchar_t *code = jResp.stringOf(L"code");
    const wchar_t *Id = jResp.stringOf(L"decisionTable.id");
    bool isSuccess = jResp.BoolOf(L"isSuccess");
    const wchar_t *message = jResp.stringOf(L"message");
    int i = 0;
    int count_i = jResp.SizeOfArray(L"decisionTable.parameters");
    while (i < count_i) {
        jResp.put_I(i);
        i = i + 1;
    }

    i = 0;
    count_i = jResp.SizeOfArray(L"decisionTable.sourceCriteria");
    while (i < count_i) {
        jResp.put_I(i);
        i = i + 1;
    }
    }

Curl Command

curl -X POST
	-H "Authorization: Bearer <access_token>"
	-d '{
   "setupName":"Product Qualificiation eligibility",
   "fullName":"ProductQualificationEligibility",
   "description":"Eligiblity of Products using Qualification Rules",
   "sourceObject":"AccountFeed",
   "status":"Draft",
   "conditionType":"Any",
   "conditionCriteria":"1 OR 2 OR 3",
   "parameters":[
      {
         "fieldName":"IsDeleted",
         "usage":"INPUT",
         "operator":"Equals",
         "sequence":"1"
      },
      {
         "fieldName":"Id",
         "usage":"INPUT",
         "operator":"Equals",
         "sequence":"2"
      },
      {
         "fieldName":"Title",
         "usage":"INPUT",
         "operator":"Equals",
         "sequence":"3"
      },
      {
         "fieldName":"CreatedById",
         "usage":"OUTPUT"
      }
   ]
}'
https://domain.com/services/data/v{{version}}/connect/business-rules/decision-table/definitions

Postman Collection Item JSON

{
  "name": "Create Table",
  "request": {
    "method": "POST",
    "header": [
    ],
    "body": {
      "mode": "raw",
      "raw": "{\n   \"setupName\":\"Product Qualificiation eligibility\",\n   \"fullName\":\"ProductQualificationEligibility\",\n   \"description\":\"Eligiblity of Products using Qualification Rules\",\n   \"sourceObject\":\"AccountFeed\",\n   \"status\":\"Draft\",\n   \"conditionType\":\"Any\",\n   \"conditionCriteria\":\"1 OR 2 OR 3\",\n   \"parameters\":[\n      {\n         \"fieldName\":\"IsDeleted\",\n         \"usage\":\"INPUT\",\n         \"operator\":\"Equals\",\n         \"sequence\":\"1\"\n      },\n      {\n         \"fieldName\":\"Id\",\n         \"usage\":\"INPUT\",\n         \"operator\":\"Equals\",\n         \"sequence\":\"2\"\n      },\n      {\n         \"fieldName\":\"Title\",\n         \"usage\":\"INPUT\",\n         \"operator\":\"Equals\",\n         \"sequence\":\"3\"\n      },\n      {\n         \"fieldName\":\"CreatedById\",\n         \"usage\":\"OUTPUT\"\n      }\n   ]\n}",
      "options": {
        "raw": {
          "language": "json"
        }
      }
    },
    "url": {
      "raw": "{{_endpoint}}/services/data/v{{version}}/connect/business-rules/decision-table/definitions",
      "host": [
        "{{_endpoint}}"
      ],
      "path": [
        "services",
        "data",
        "v{{version}}",
        "connect",
        "business-rules",
        "decision-table",
        "definitions"
      ]
    },
    "description": "# Decision Table Definitions (POST)\n\nCreate a decision table definition. A decision table definition contains all the details required to create a decision table.Resource\n\n```\n/connect/business-rules/decision-table/definitions\n\n ```\n\nResource Example\n\n```\nhttps://yourInstance.salesforce.com/services/data/v59.0/connect/business-rules/decision-table/definitions\n\n ```\n\nAvailable version\n\n58.0\n\nRequires Chatter\n\nNo\n\nHTTP methods\n\nPOST\n\nJSON example for a single object source\n\n```\n{\n   \"setupName\":\"Product Qualificiation eligibility\",\n   \"fullName\":\"ProductQualificationEligibility\",\n   \"description\":\"Eligiblity of Products using Qualification Rules\",\n   \"usageType\":\"ProductEligibility\",\n   \"sourceType\":\"SingleSobject\",\n   \"sourceObject\":\"AccountFeed\",\n   \"status\":\"Draft\",\n   \"decisionResultPolicy\":\"UniqueValues\",\n   \"collectOperator\":\"Count\",\n   \"conditionType\":\"Any\",\n   \"conditionCriteria\":\"1 OR 2 OR 3\",\n   \"parameters\":[\n      {\n         \"fieldName\":\"IsDeleted\",\n         \"usage\":\"INPUT\",\n         \"operator\":\"Equals\",\n         \"sequence\":\"1\"\n      },\n      {\n         \"fieldName\":\"Id\",\n         \"usage\":\"INPUT\",\n         \"operator\":\"Equals\",\n         \"sequence\":\"2\"\n      },\n      {\n         \"fieldName\":\"Title\",\n         \"usage\":\"INPUT\",\n         \"operator\":\"Equals\",\n         \"sequence\":\"3\"\n      },\n      {\n         \"fieldName\":\"CreatedById\",\n         \"usage\":\"OUTPUT\"\n      }\n   ]\n}\n\n ```\n\nJSON example for a multi-object source\n\n```\n{\n   \"setupName\":\"Jumbo Pricing Definition\",\n   \"fullName\":\"JumboPricingDefinition\",\n   \"description\":\"Join all the DT definitions into one jumbo pricing definition\",\n   \"usageType\":\"ProductEligibility\",\n   \"type\":\"LowVolume\",\n   \"sourceType\":\"MultipleSobjects\",\n   \"sourceObject\":\"AccountFeed\",\n   \"status\":\"Draft\",\n   \"decisionResultPolicy\":\"UniqueValues\",\n   \"collectOperator\":\"Count\",\n   \"sourceconditionLogic\":\"1 AND 2 AND 3\",\n   \"conditionType\":\"Any\",\n   \"conditionCriteria\":\"1 OR 2 OR 3 OR 4 OR 5\",\n   \"parameters\":[\n      {\n         \"fieldName\":\"IsDeleted\",\n         \"usage\":\"INPUT\",\n         \"operator\":\"Equals\",\n         \"sequence\":\"1\",\n         \"columnMapping\":\"IsDeleted\"\n      },\n      {\n         \"fieldName\":\"Id\",\n         \"usage\":\"INPUT\",\n         \"operator\":\"Equals\",\n         \"sequence\":\"2\",\n         \"columnMapping\":\"Id\"\n      },\n      {\n         \"fieldName\":\"Title\",\n         \"usage\":\"INPUT\",\n         \"operator\":\"Equals\",\n         \"sequence\":\"3\",\n         \"columnMapping\":\"Title\"\n      },\n      {\n         \"fieldName\":\"OldvalNumber\",\n         \"usage\":\"INPUT\",\n         \"operator\":\"Equals\",\n         \"sequence\":\"4\",\n         \"columnMapping\":\"AccountHistory.OldvalNumber\"\n      },\n      {\n         \"fieldName\":\"OldvalString\",\n         \"usage\":\"INPUT\",\n         \"operator\":\"Equals\",\n         \"sequence\":\"5\",\n         \"columnMapping\":\"AccountHistory.OldvalString\"\n      },\n      {\n         \"fieldName\":\"CreatedById\",\n         \"usage\":\"OUTPUT\",\n         \"columnMapping\":\"CreatedById\"\n      },\n      {\n         \"fieldName\":\"NewvalNumber\",\n         \"usage\":\"OUTPUT\",\n         \"columnMapping\":\"AccountHistory.NewvalNumber\"\n      },\n      {\n         \"fieldName\":\"NewvalString\",\n         \"usage\":\"OUTPUT\",\n         \"columnMapping\":\"AccountHistory.NewvalString\"\n      }\n   ]\n   \"sourceCriteria\":[\n      {\n         \"sourceFieldName\":\"OldvalString\",\n         \"value\":\"5\",\n         \"operator\":\"Equals\",\n         \"valueType\":\"Parameter\",\n         \"sequenceNumber\":\"1\"\n      }\n   ]\n}\n\n ```\n\nRequest body for POSTProperties\n\n| Name | Type | Description | Required or Optional | Available Version |\n| --- | --- | --- | --- | --- |\n| collectOperator | String | Operator to apply a filter to outputs. Possible values are:  <br>  <br>\\- Count  <br>  <br>\\- Maximum  <br>  <br>\\- Minimum  <br>  <br>\\- None  <br>  <br>\\- Sum | Optional | 58.0 |\n| conditionCriteria | String | Custom logic applied on the decision table columns to decide how the input fields are processed. | Optional  <br>  <br>Required when the condition type is Custom. | 58.0 |\n| conditionType | String | Condition logic for input fields. Possible values are:  <br>  <br>\\- All  <br>  <br>\\- Any  <br>  <br>\\- Custom | Optional | 58.0 |\n| description | String | Description of the decision table. | Optional | 58.0 |\n| decisionResultPolicy | String | Results policy to filter results of the decision table. Possible values are:  <br>  <br>\\- AnyValue  <br>  <br>\\- CollectOperator  <br>  <br>\\- FirstMatch  <br>  <br>\\- OutputOrder  <br>  <br>\\- Priority  <br>  <br>\\- RuleOrder  <br>  <br>\\- UniqueValues | Optional |  |\n| fullName | String | Unique name of the rule definition. | Required | 58.0 |\n| isSetCollectOperator | Boolean | For internal use only.  <br>  <br>Indicates whether the collectOperator is enabled (true) or not (false). | Optional | 58.0 |\n| isSetConditionCriteria | Boolean | For internal use only.  <br>  <br>Indicates whether the conditionCriteria field is enabled (true) or not (false). | Optional | 58.0 |\n| isSetConditionType | Boolean | For internal use only.  <br>  <br>Indicates whether the conditionType field is enabled (true) or not (false). | Optional | 58.0 |\n| isSetDescription | Boolean | For internal use only.  <br>  <br>Indicates whether the description field is enabled (true) or not (false). | Optional | 58.0 |\n| isSetDecisionResultPolicy | Boolean | For internal use only.  <br>  <br>Indicates whether the DecisionResultPolicy field is enabled (true) or not (false). | Optional | 58.0 |\n| isSetFullName | Boolean | For internal use only.  <br>  <br>Indicates whether the FullName field is enabled (true) or not (false). | Optional | 58.0 |\n| isSetParameters | Boolean | For internal use only. Indicates whether the parameters field is enabled (true) or not (false). | Optional | 58.0 |\n| isSetSetupName | Boolean | For internal use only.  <br>  <br>Indicates whether the setupName field is enabled (true) or not (false). | Optional | 58.0 |\n| isSetSourceconditionLogic | Boolean | For internal use only.  <br>  <br>Indicates whether the sourceConditionLogic field is enabled (true) or not (false). | Optional | 58.0 |\n| isSetSourceCriteria | Boolean | For internal use only.  <br>  <br>Indicates whether the sourceCriteria field is enabled (true) or not (false). | Optional | 58.0 |\n| isSetSourceObject | Boolean | For internal use only.  <br>  <br>Indicates whether the sourceObject field is enabled (true) or not (false). | Optional | 58.0 |\n| isSetSourceType | Boolean | For internal use only.  <br>  <br>Indicates whether the sourceType is enabled (true) or not (false). | Optional | 58.0 |\n| isSetType | Boolean | For internal use only.  <br>  <br>Indicates whether the type field is enabled (true) or not (false). | Optional | 58.0 |\n| isSetUsageType | Boolean | For internal use only.  <br>  <br>Indicates whether the UsageType field is enabled (true) or not (false). | Optional | 58.0 |\n| parameters | [Decision Table Parameter Input](https://developer.salesforce.com/docs/atlas.en-us.industries_reference.meta/industries_reference/connect_requests_decision_table_parameter_input.htm)\\[\\] | Array of input and output fields for the decision table. | Optional | 58.0 |\n| setupName | String | Name of the decision table. | Required | 58.0 |\n| sourceconditionLogic | String | Custom logic to filter the decision table rows. | Optional | 58.0 |\n| sourceCriteria | [Decision Table Source Criteria Input](https://developer.salesforce.com/docs/atlas.en-us.industries_reference.meta/industries_reference/connect_requests_decision_table_source_criteria_input.htm)\\[\\] | Output array representation of source filters for the decision table rows, such as, fieldName, operators, valueType, and more. | Optional | 58.0 |\n| sourceObject | String | Object containing business rules for the decision table to read. | Required | 58.0 |\n| sourceType | String | Type of source to obtain decision table data. Possible values are:  <br>  <br>\\- CsvUpload  <br>  <br>\\- MultipleSobjects  <br>  <br>\\- SingleSobject | Required | 58.0 |\n| status | String | Status of the decision table. Possible values are:  <br>  <br>\\- ActivationInProgress  <br>  <br>\\- ActivationInProgress  <br>  <br>\\- Draft  <br>  <br>\\- Inactive | Required | 58.0 |\n| type | String | Type of the decision table. Possible values are:  <br>  <br>\\- HighVolume  <br>  <br>\\- LowVolume | Optional | 58.0 |\n| usageType | String | Process type that uses the decision table. Possible values are:  <br>  <br>\\- Pricing  <br>  <br>\\- ProductEligibility | Optional | 58.0 |\n\nResponse body for POST\n\n[Decision Table Output](https://developer.salesforce.com/docs/atlas.en-us.industries_reference.meta/industries_reference/connect_responses_decision_table_output.htm)\n\n# Decision Table Output\n\nOutput representation of the decision table details.JSON example for GET, POST, and PATCH\n\n```\n{\n   \"code\":\"200\",\n   \"decisionTable\":{\n      \"collectOperator\":\"Count\",\n      \"conditionCriteria\":\"1 OR 2 OR 3\",\n      \"conditionType\":\"Any\",\n      \"decisionResultPolicy\":\"UniqueValues\",\n      \"description\":\"Eligiblity of Products using Qualification Rules\",\n      \"id\":\"0lDxx00000000BJ\",\n      \"parameters\":[\n         {\n            \"fieldName\":\"IsDeleted\",\n            \"isGroupByField\":false,\n            \"isPriority\":false,\n            \"operator\":\"Equals\",\n            \"sequence\":1,\n            \"usage\":\"Input\"\n         },\n         {\n            \"fieldName\":\"CreatedById\",\n            \"isGroupByField\":false,\n            \"isPriority\":false,\n            \"usage\":\"Output\"\n         },\n         {\n            \"fieldName\":\"Title\",\n            \"isGroupByField\":false,\n            \"isPriority\":false,\n            \"operator\":\"Equals\",\n            \"sequence\":3,\n            \"usage\":\"Input\"\n         },\n         {\n            \"fieldName\":\"Id\",\n            \"isGroupByField\":false,\n            \"isPriority\":false,\n            \"operator\":\"Equals\",\n            \"sequence\":2,\n            \"usage\":\"Input\"\n         }\n      ],\n      \"setupName\":\"Product Qualificiation eligibility3\",\n      \"sourceCriteria\":[\n         \n      ],\n      \"sourceObject\":\"AccountFeed\",\n      \"sourceType\":\"SingleSobject\",\n      \"sourceconditionLogic\":\"1 AND 2 AND 3\",\n      \"status\":\"Draft\"\n   },\n   \"isSuccess\":true,\n   \"message\":\"\"\n}\n\n ```\n\nJSON example for DELETE\n\n```\n{\n   \"code\":\"200\",\n   \"isSuccess\":true,\n   \"message\":\"\"\n}\n\n ```\n\n| Property Name | Type | Description | Filter Group and Version | Available Version |\n| --- | --- | --- | --- | --- |\n| code | String | Response code from the API request. | Small, 58.0 | 58.0 |\n| decisionTable | [Decision Table Definition Output](https://developer.salesforce.com/docs/atlas.en-us.industries_reference.meta/industries_reference/connect_responses_decision_table_definition_output.htm) | Details of the decision table definition associated with the decision table. | Small, 58.0 | 58.0 |\n| isSuccess | Boolean | Indicates whether the API request is successful (true) or not (false). | Small, 58.0 | 58.0 |\n| message | String | Error message when the API request fails. | Small, 58.0 | 58.0 |"
  },
  "response": [
    {
      "name": "Status201-Success",
      "originalRequest": {
        "method": "POST",
        "header": [
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n   \"setupName\":\"Product Qualificiation eligibility\",\n   \"fullName\":\"ProductQualificationEligibility\",\n   \"description\":\"Eligiblity of Products using Qualification Rules\",\n   \"sourceObject\":\"AccountFeed\",\n   \"status\":\"Draft\",\n   \"conditionType\":\"Any\",\n   \"conditionCriteria\":\"1 OR 2 OR 3\",\n   \"parameters\":[\n      {\n         \"fieldName\":\"IsDeleted\",\n         \"usage\":\"INPUT\",\n         \"operator\":\"Equals\",\n         \"sequence\":\"1\"\n      },\n      {\n         \"fieldName\":\"Id\",\n         \"usage\":\"INPUT\",\n         \"operator\":\"Equals\",\n         \"sequence\":\"2\"\n      },\n      {\n         \"fieldName\":\"Title\",\n         \"usage\":\"INPUT\",\n         \"operator\":\"Equals\",\n         \"sequence\":\"3\"\n      },\n      {\n         \"fieldName\":\"CreatedById\",\n         \"usage\":\"OUTPUT\"\n      }\n   ]\n}",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{_endpoint}}/services/data/v{{version}}/connect/business-rules/decision-table/definitions",
          "host": [
            "{{_endpoint}}"
          ],
          "path": [
            "services",
            "data",
            "v{{version}}",
            "connect",
            "business-rules",
            "decision-table",
            "definitions"
          ]
        }
      },
      "status": "Created",
      "code": 201,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Date",
          "value": "Tue, 19 Sep 2023 12:41:36 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    \"code\": \"200\",\n    \"decisionTable\": {\n        \"id\": \"0lDHo0000008Pnt\",\n        \"parameters\": [],\n        \"sourceCriteria\": []\n    },\n    \"isSuccess\": true,\n    \"message\": \"\"\n}"
    }
  ]
}