Chilkat Online Tools

C / Salesforce Platform APIs / Get Most Recently Used List View Metadata

Back to Collection Items

#include <C_CkHttp.h>
#include <C_CkStringBuilder.h>
#include <C_CkJsonObject.h>

void ChilkatSample(void)
    {
    HCkHttp http;
    BOOL success;
    HCkStringBuilder sbResponseBody;
    HCkJsonObject jResp;
    int respStatusCode;
    const char *fieldApiName;
    const char *lookupId;
    BOOL sortable;
    BOOL cloneable;
    BOOL createable;
    BOOL deletable;
    const char *eTag;
    const char *filterLogicString;
    const char *label;
    const char *Id;
    const char *ListViewApiName;
    const char *ObjectApiName;
    const char *v_Type;
    BOOL updateable;
    int Site;
    int Owner_Alias;
    int Phone;
    int Name;
    BOOL ColumnWrapSite;
    BOOL ColumnWrapOwner_Alias;
    BOOL ColumnWrapPhone;
    BOOL ColumnWrapName;
    const char *visibility;
    BOOL visibilityEditable;
    int i;
    int count_i;

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

    http = CkHttp_Create();

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

    sbResponseBody = CkStringBuilder_Create();
    success = CkHttp_QuickGetSb(http,"https://domain.com/services/data/v{{version}}/ui-api/mru-list-info/:SOBJECT_API_NAME",sbResponseBody);
    if (success == FALSE) {
        printf("%s\n",CkHttp_lastErrorText(http));
        CkHttp_Dispose(http);
        CkStringBuilder_Dispose(sbResponseBody);
        return;
    }

    jResp = CkJsonObject_Create();
    CkJsonObject_LoadSb(jResp,sbResponseBody);
    CkJsonObject_putEmitCompact(jResp,FALSE);

    printf("Response Body:\n");
    printf("%s\n",CkJsonObject_emit(jResp));

    respStatusCode = CkHttp_getLastStatus(http);
    printf("Response Status Code = %d\n",respStatusCode);
    if (respStatusCode >= 400) {
        printf("Response Header:\n");
        printf("%s\n",CkHttp_lastHeader(http));
        printf("Failed.\n");
        CkHttp_Dispose(http);
        CkStringBuilder_Dispose(sbResponseBody);
        CkJsonObject_Dispose(jResp);
        return;
    }

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

    // {
    //   "cloneable": false,
    //   "createable": true,
    //   "deletable": false,
    //   "displayColumns": [
    //     {
    //       "fieldApiName": "Name",
    //       "label": "Account Name",
    //       "lookupId": null,
    //       "sortable": true
    //     },
    //     {
    //       "fieldApiName": "Site",
    //       "label": "Account Site",
    //       "lookupId": null,
    //       "sortable": true
    //     },
    //     {
    //       "fieldApiName": "Phone",
    //       "label": "Phone",
    //       "lookupId": null,
    //       "sortable": true
    //     },
    //     {
    //       "fieldApiName": "Owner.Alias",
    //       "label": "Account Owner Alias",
    //       "lookupId": null,
    //       "sortable": true
    //     }
    //   ],
    //   "eTag": "4c63719f66dbb57c7cb86c2effc5f08b",
    //   "filterLogicString": null,
    //   "filteredByInfo": [
    //   ],
    //   "label": "Recently Viewed",
    //   "listReference": {
    //     "id": null,
    //     "listViewApiName": null,
    //     "objectApiName": "Account",
    //     "type": "mru"
    //   },
    //   "objectApiNames": [
    //   ],
    //   "orderedByInfo": [
    //   ],
    //   "updateable": false,
    //   "userPreferences": {
    //     "columnWidths": {
    //       "Site": -1,
    //       "Owner.Alias": -1,
    //       "Phone": -1,
    //       "Name": -1
    //     },
    //     "columnWrap": {
    //       "Site": false,
    //       "Owner.Alias": false,
    //       "Phone": false,
    //       "Name": false
    //     }
    //   },
    //   "visibility": "Public",
    //   "visibilityEditable": false
    // }

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

    cloneable = CkJsonObject_BoolOf(jResp,"cloneable");
    createable = CkJsonObject_BoolOf(jResp,"createable");
    deletable = CkJsonObject_BoolOf(jResp,"deletable");
    eTag = CkJsonObject_stringOf(jResp,"eTag");
    filterLogicString = CkJsonObject_stringOf(jResp,"filterLogicString");
    label = CkJsonObject_stringOf(jResp,"label");
    Id = CkJsonObject_stringOf(jResp,"listReference.id");
    ListViewApiName = CkJsonObject_stringOf(jResp,"listReference.listViewApiName");
    ObjectApiName = CkJsonObject_stringOf(jResp,"listReference.objectApiName");
    v_Type = CkJsonObject_stringOf(jResp,"listReference.type");
    updateable = CkJsonObject_BoolOf(jResp,"updateable");
    Site = CkJsonObject_IntOf(jResp,"userPreferences.columnWidths.Site");
    Owner_Alias = CkJsonObject_IntOf(jResp,"userPreferences.columnWidths.\"Owner.Alias\"");
    Phone = CkJsonObject_IntOf(jResp,"userPreferences.columnWidths.Phone");
    Name = CkJsonObject_IntOf(jResp,"userPreferences.columnWidths.Name");
    ColumnWrapSite = CkJsonObject_BoolOf(jResp,"userPreferences.columnWrap.Site");
    ColumnWrapOwner_Alias = CkJsonObject_BoolOf(jResp,"userPreferences.columnWrap.\"Owner.Alias\"");
    ColumnWrapPhone = CkJsonObject_BoolOf(jResp,"userPreferences.columnWrap.Phone");
    ColumnWrapName = CkJsonObject_BoolOf(jResp,"userPreferences.columnWrap.Name");
    visibility = CkJsonObject_stringOf(jResp,"visibility");
    visibilityEditable = CkJsonObject_BoolOf(jResp,"visibilityEditable");
    i = 0;
    count_i = CkJsonObject_SizeOfArray(jResp,"displayColumns");
    while (i < count_i) {
        CkJsonObject_putI(jResp,i);
        fieldApiName = CkJsonObject_stringOf(jResp,"displayColumns[i].fieldApiName");
        label = CkJsonObject_stringOf(jResp,"displayColumns[i].label");
        lookupId = CkJsonObject_stringOf(jResp,"displayColumns[i].lookupId");
        sortable = CkJsonObject_BoolOf(jResp,"displayColumns[i].sortable");
        i = i + 1;
    }

    i = 0;
    count_i = CkJsonObject_SizeOfArray(jResp,"filteredByInfo");
    while (i < count_i) {
        CkJsonObject_putI(jResp,i);
        i = i + 1;
    }

    i = 0;
    count_i = CkJsonObject_SizeOfArray(jResp,"objectApiNames");
    while (i < count_i) {
        CkJsonObject_putI(jResp,i);
        i = i + 1;
    }

    i = 0;
    count_i = CkJsonObject_SizeOfArray(jResp,"orderedByInfo");
    while (i < count_i) {
        CkJsonObject_putI(jResp,i);
        i = i + 1;
    }



    CkHttp_Dispose(http);
    CkStringBuilder_Dispose(sbResponseBody);
    CkJsonObject_Dispose(jResp);

    }

Curl Command

curl -X GET
	-H "Authorization: Bearer <access_token>"
https://domain.com/services/data/v{{version}}/ui-api/mru-list-info/:SOBJECT_API_NAME

Postman Collection Item JSON

{
  "name": "Get Most Recently Used List View Metadata",
  "event": [
    {
      "listen": "prerequest",
      "script": {
        "exec": [
          ""
        ],
        "type": "text/javascript"
      }
    }
  ],
  "protocolProfileBehavior": {
    "disableBodyPruning": true
  },
  "request": {
    "method": "GET",
    "header": [
    ],
    "body": {
      "mode": "raw",
      "raw": "",
      "options": {
        "raw": {
          "language": "json"
        }
      }
    },
    "url": {
      "raw": "{{_endpoint}}/services/data/v{{version}}/ui-api/mru-list-info/:SOBJECT_API_NAME",
      "host": [
        "{{_endpoint}}"
      ],
      "path": [
        "services",
        "data",
        "v{{version}}",
        "ui-api",
        "mru-list-info",
        ":SOBJECT_API_NAME"
      ],
      "variable": [
        {
          "key": "SOBJECT_API_NAME",
          "value": "",
          "description": "Object API name"
        }
      ]
    },
    "description": "Returns metadata for an object’s most recently viewed (MRU) list view."
  },
  "response": [
    {
      "name": "Get Most Recently Used List View Metadata",
      "originalRequest": {
        "method": "GET",
        "header": [
        ],
        "body": {
          "mode": "raw",
          "raw": "",
          "options": {
            "raw": {
              "language": "json"
            }
          }
        },
        "url": {
          "raw": "{{_endpoint}}/services/data/v{{version}}/ui-api/mru-list-info/:SOBJECT_API_NAME",
          "host": [
            "{{_endpoint}}"
          ],
          "path": [
            "services",
            "data",
            "v{{version}}",
            "ui-api",
            "mru-list-info",
            ":SOBJECT_API_NAME"
          ],
          "variable": [
            {
              "key": "SOBJECT_API_NAME",
              "value": "Account",
              "description": "Object API name"
            }
          ]
        }
      },
      "status": "OK",
      "code": 200,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Date",
          "value": "Fri, 06 Oct 2023 10:00:00 GMT"
        },
        {
          "key": "Strict-Transport-Security",
          "value": "max-age=63072000; includeSubDomains"
        },
        {
          "key": "X-Content-Type-Options",
          "value": "nosniff"
        },
        {
          "key": "X-Robots-Tag",
          "value": "none"
        },
        {
          "key": "Cache-Control",
          "value": "no-cache,must-revalidate,max-age=0,no-store,private"
        },
        {
          "key": "ETag",
          "value": "\"4c63719f66dbb57c7cb86c2effc5f08b--gzip\""
        },
        {
          "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    \"cloneable\": false,\n    \"createable\": true,\n    \"deletable\": false,\n    \"displayColumns\": [\n        {\n            \"fieldApiName\": \"Name\",\n            \"label\": \"Account Name\",\n            \"lookupId\": null,\n            \"sortable\": true\n        },\n        {\n            \"fieldApiName\": \"Site\",\n            \"label\": \"Account Site\",\n            \"lookupId\": null,\n            \"sortable\": true\n        },\n        {\n            \"fieldApiName\": \"Phone\",\n            \"label\": \"Phone\",\n            \"lookupId\": null,\n            \"sortable\": true\n        },\n        {\n            \"fieldApiName\": \"Owner.Alias\",\n            \"label\": \"Account Owner Alias\",\n            \"lookupId\": null,\n            \"sortable\": true\n        }\n    ],\n    \"eTag\": \"4c63719f66dbb57c7cb86c2effc5f08b\",\n    \"filterLogicString\": null,\n    \"filteredByInfo\": [],\n    \"label\": \"Recently Viewed\",\n    \"listReference\": {\n        \"id\": null,\n        \"listViewApiName\": null,\n        \"objectApiName\": \"Account\",\n        \"type\": \"mru\"\n    },\n    \"objectApiNames\": [],\n    \"orderedByInfo\": [],\n    \"updateable\": false,\n    \"userPreferences\": {\n        \"columnWidths\": {\n            \"Site\": -1,\n            \"Owner.Alias\": -1,\n            \"Phone\": -1,\n            \"Name\": -1\n        },\n        \"columnWrap\": {\n            \"Site\": false,\n            \"Owner.Alias\": false,\n            \"Phone\": false,\n            \"Name\": false\n        }\n    },\n    \"visibility\": \"Public\",\n    \"visibilityEditable\": false\n}"
    }
  ]
}