SQL Server / Salesforce Platform APIs / Get Most Recently Used List View Metadata
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
-- 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
-- Adds the "Authorization: Bearer <access_token>" header.
EXEC sp_OASetProperty @http, 'AuthToken', '<access_token>'
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 @http, 'QuickGetSb', @success OUT, 'https://domain.com/services/data/v{{version}}/ui-api/mru-list-info/:SOBJECT_API_NAME', @sbResponseBody
IF @success = 0
BEGIN
EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @sbResponseBody
RETURN
END
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 @http, 'LastStatus', @respStatusCode OUT
PRINT 'Response Status Code = ' + @respStatusCode
IF @respStatusCode >= 400
BEGIN
PRINT 'Response Header:'
EXEC sp_OAGetProperty @http, 'LastHeader', @sTmp0 OUT
PRINT @sTmp0
PRINT 'Failed.'
EXEC @hr = sp_OADestroy @http
EXEC @hr = sp_OADestroy @sbResponseBody
EXEC @hr = sp_OADestroy @jResp
RETURN
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
DECLARE @fieldApiName nvarchar(4000)
DECLARE @lookupId nvarchar(4000)
DECLARE @sortable int
DECLARE @cloneable int
EXEC sp_OAMethod @jResp, 'BoolOf', @cloneable OUT, 'cloneable'
DECLARE @createable int
EXEC sp_OAMethod @jResp, 'BoolOf', @createable OUT, 'createable'
DECLARE @deletable int
EXEC sp_OAMethod @jResp, 'BoolOf', @deletable OUT, 'deletable'
DECLARE @eTag nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @eTag OUT, 'eTag'
DECLARE @filterLogicString nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @filterLogicString OUT, 'filterLogicString'
DECLARE @label nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @label OUT, 'label'
DECLARE @Id nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @Id OUT, 'listReference.id'
DECLARE @ListViewApiName nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @ListViewApiName OUT, 'listReference.listViewApiName'
DECLARE @ObjectApiName nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @ObjectApiName OUT, 'listReference.objectApiName'
DECLARE @v_Type nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @v_Type OUT, 'listReference.type'
DECLARE @updateable int
EXEC sp_OAMethod @jResp, 'BoolOf', @updateable OUT, 'updateable'
DECLARE @Site int
EXEC sp_OAMethod @jResp, 'IntOf', @Site OUT, 'userPreferences.columnWidths.Site'
DECLARE @Owner_Alias int
EXEC sp_OAMethod @jResp, 'IntOf', @Owner_Alias OUT, 'userPreferences.columnWidths."Owner.Alias"'
DECLARE @Phone int
EXEC sp_OAMethod @jResp, 'IntOf', @Phone OUT, 'userPreferences.columnWidths.Phone'
DECLARE @Name int
EXEC sp_OAMethod @jResp, 'IntOf', @Name OUT, 'userPreferences.columnWidths.Name'
DECLARE @ColumnWrapSite int
EXEC sp_OAMethod @jResp, 'BoolOf', @ColumnWrapSite OUT, 'userPreferences.columnWrap.Site'
DECLARE @ColumnWrapOwner_Alias int
EXEC sp_OAMethod @jResp, 'BoolOf', @ColumnWrapOwner_Alias OUT, 'userPreferences.columnWrap."Owner.Alias"'
DECLARE @ColumnWrapPhone int
EXEC sp_OAMethod @jResp, 'BoolOf', @ColumnWrapPhone OUT, 'userPreferences.columnWrap.Phone'
DECLARE @ColumnWrapName int
EXEC sp_OAMethod @jResp, 'BoolOf', @ColumnWrapName OUT, 'userPreferences.columnWrap.Name'
DECLARE @visibility nvarchar(4000)
EXEC sp_OAMethod @jResp, 'StringOf', @visibility OUT, 'visibility'
DECLARE @visibilityEditable int
EXEC sp_OAMethod @jResp, 'BoolOf', @visibilityEditable OUT, 'visibilityEditable'
DECLARE @i int
SELECT @i = 0
DECLARE @count_i int
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'displayColumns'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
EXEC sp_OAMethod @jResp, 'StringOf', @fieldApiName OUT, 'displayColumns[i].fieldApiName'
EXEC sp_OAMethod @jResp, 'StringOf', @label OUT, 'displayColumns[i].label'
EXEC sp_OAMethod @jResp, 'StringOf', @lookupId OUT, 'displayColumns[i].lookupId'
EXEC sp_OAMethod @jResp, 'BoolOf', @sortable OUT, 'displayColumns[i].sortable'
SELECT @i = @i + 1
END
SELECT @i = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'filteredByInfo'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
SELECT @i = @i + 1
END
SELECT @i = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'objectApiNames'
WHILE @i < @count_i
BEGIN
EXEC sp_OASetProperty @jResp, 'I', @i
SELECT @i = @i + 1
END
SELECT @i = 0
EXEC sp_OAMethod @jResp, 'SizeOfArray', @count_i OUT, 'orderedByInfo'
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 @sbResponseBody
EXEC @hr = sp_OADestroy @jResp
END
GO
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}"
}
]
}