Chilkat Online Tools

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

Back to Collection Items

var
http: TChilkatHttp;
success: Integer;
sbResponseBody: TChilkatStringBuilder;
jResp: TChilkatJsonObject;
respStatusCode: Integer;
fieldApiName: WideString;
lookupId: WideString;
sortable: Integer;
cloneable: Integer;
createable: Integer;
deletable: Integer;
eTag: WideString;
filterLogicString: WideString;
label: WideString;
Id: WideString;
ListViewApiName: WideString;
ObjectApiName: WideString;
v_Type: WideString;
updateable: Integer;
Site: Integer;
Owner_Alias: Integer;
Phone: Integer;
Name: Integer;
ColumnWrapSite: Integer;
ColumnWrapOwner_Alias: Integer;
ColumnWrapPhone: Integer;
ColumnWrapName: Integer;
visibility: WideString;
visibilityEditable: Integer;
i: Integer;
count_i: Integer;

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

http := TChilkatHttp.Create(Self);

// Adds the "Authorization: Bearer <access_token>" header.
http.AuthToken := '<access_token>';

sbResponseBody := TChilkatStringBuilder.Create(Self);
success := http.QuickGetSb('https://domain.com/services/data/v{{version}}/ui-api/mru-list-info/:SOBJECT_API_NAME',sbResponseBody.ControlInterface);
if (success = 0) then
  begin
    Memo1.Lines.Add(http.LastErrorText);
    Exit;
  end;

jResp := TChilkatJsonObject.Create(Self);
jResp.LoadSb(sbResponseBody.ControlInterface);
jResp.EmitCompact := 0;

Memo1.Lines.Add('Response Body:');
Memo1.Lines.Add(jResp.Emit());

respStatusCode := http.LastStatus;
Memo1.Lines.Add('Response Status Code = ' + IntToStr(respStatusCode));
if (respStatusCode >= 400) then
  begin
    Memo1.Lines.Add('Response Header:');
    Memo1.Lines.Add(http.LastHeader);
    Memo1.Lines.Add('Failed.');
    Exit;
  end;

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

cloneable := jResp.BoolOf('cloneable');
createable := jResp.BoolOf('createable');
deletable := jResp.BoolOf('deletable');
eTag := jResp.StringOf('eTag');
filterLogicString := jResp.StringOf('filterLogicString');
label := jResp.StringOf('label');
Id := jResp.StringOf('listReference.id');
ListViewApiName := jResp.StringOf('listReference.listViewApiName');
ObjectApiName := jResp.StringOf('listReference.objectApiName');
v_Type := jResp.StringOf('listReference.type');
updateable := jResp.BoolOf('updateable');
Site := jResp.IntOf('userPreferences.columnWidths.Site');
Owner_Alias := jResp.IntOf('userPreferences.columnWidths."Owner.Alias"');
Phone := jResp.IntOf('userPreferences.columnWidths.Phone');
Name := jResp.IntOf('userPreferences.columnWidths.Name');
ColumnWrapSite := jResp.BoolOf('userPreferences.columnWrap.Site');
ColumnWrapOwner_Alias := jResp.BoolOf('userPreferences.columnWrap."Owner.Alias"');
ColumnWrapPhone := jResp.BoolOf('userPreferences.columnWrap.Phone');
ColumnWrapName := jResp.BoolOf('userPreferences.columnWrap.Name');
visibility := jResp.StringOf('visibility');
visibilityEditable := jResp.BoolOf('visibilityEditable');
i := 0;
count_i := jResp.SizeOfArray('displayColumns');
while i < count_i do
  begin
    jResp.I := i;
    fieldApiName := jResp.StringOf('displayColumns[i].fieldApiName');
    label := jResp.StringOf('displayColumns[i].label');
    lookupId := jResp.StringOf('displayColumns[i].lookupId');
    sortable := jResp.BoolOf('displayColumns[i].sortable');
    i := i + 1;
  end;

i := 0;
count_i := jResp.SizeOfArray('filteredByInfo');
while i < count_i do
  begin
    jResp.I := i;
    i := i + 1;
  end;

i := 0;
count_i := jResp.SizeOfArray('objectApiNames');
while i < count_i do
  begin
    jResp.I := i;
    i := i + 1;
  end;

i := 0;
count_i := jResp.SizeOfArray('orderedByInfo');
while i < count_i do
  begin
    jResp.I := i;
    i := i + 1;
  end;

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