0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

List Viewのメタデータを取得する

Last updated at Posted at 2024-04-01

このアイデアを見てMetaData APIを使えば取得できるだろうと思っていましたが、Postmanからは思ったようなメタデータが取得できないですね。

リスト ビューがまだ表示されていることを確認するために、表示設定が「すべてのユーザーに表示 (パートナーおよびカスタマー ポータル ユーザーを含む)」に設定されている、最近変更されたすべてのケース リスト ビューを表示する単純なレポートがあれば便利です。顧客が見るのに適しています。

他に方法がないかと悩んでいましたが、UIのAPIが使えそうです。

オブジェクトに関連付けられたリスト ビューのコレクションを返します。

image.png

今回はAccountオブジェクトを指定してみます。

image.png

結果は以下の通りです。

{
    "count": 6,
    "currentPageToken": "0",
    "currentPageUrl": "/services/data/v60.0/ui-api/list-ui/Account?pageSize=20&pageToken=0",
    "eTag": "a49f70ad56388c3189c11d4e8cb54478",
    "lists": [
        {
            "apiName": "AllAccounts",
            "id": "00B5i00000cCVbgEAG",
            "label": "All Accounts",
            "listUiUrl": "/services/data/v60.0/ui-api/list-ui/Account/AllAccounts"
        },
        {
            "apiName": "MyAccounts",
            "id": "00B5i00000cCVbmEAG",
            "label": "My Accounts",
            "listUiUrl": "/services/data/v60.0/ui-api/list-ui/Account/MyAccounts"
        },
        {
            "apiName": "NewLastWeek",
            "id": "00B5i00000cCVbAEAW",
            "label": "New Last Week",
            "listUiUrl": "/services/data/v60.0/ui-api/list-ui/Account/NewLastWeek"
        },
        {
            "apiName": "NewThisWeek",
            "id": "00B5i00000cCVazEAG",
            "label": "New This Week",
            "listUiUrl": "/services/data/v60.0/ui-api/list-ui/Account/NewThisWeek"
        },
        {
            "apiName": "PlatinumandGoldSLACustomers",
            "id": "00B5i00000cCVbQEAW",
            "label": "Platinum and Gold SLA Customers",
            "listUiUrl": "/services/data/v60.0/ui-api/list-ui/Account/PlatinumandGoldSLACustomers"
        },
        {
            "apiName": "RecentlyViewedAccounts",
            "id": "00B5i00000cCVbfEAG",
            "label": "Recently Viewed Accounts",
            "listUiUrl": "/services/data/v60.0/ui-api/list-ui/Account/RecentlyViewedAccounts"
        }
    ],
    "nextPageToken": null,
    "nextPageUrl": null,
    "objectApiName": "Account",
    "pageSize": 20,
    "previousPageToken": null,
    "previousPageUrl": null,
    "queryString": null,
    "recentListsOnly": false
}

Recently Viewedは特別っぽいので、ここの対象にはなってないのかもれませんね。

エンドポイントが別のようです。

Tooling APIにもエンドポイントがある。

image.png

これでListViesのIdが分かったので、次にIdを使ってメタデータを取得します。

リストビューのメタデータを返します。

image.png

image.png

{
    "cloneable": true,
    "createable": true,
    "deletable": true,
    "displayColumns": [
        {
            "fieldApiName": "Name",
            "label": "Account Name",
            "lookupId": "Id",
            "sortable": true
        },
        {
            "fieldApiName": "Site",
            "label": "Account Site",
            "lookupId": null,
            "sortable": true
        },
        {
            "fieldApiName": "BillingState",
            "label": "Billing State/Province",
            "lookupId": null,
            "sortable": true
        },
        {
            "fieldApiName": "Phone",
            "label": "Phone",
            "lookupId": null,
            "sortable": true
        },
        {
            "fieldApiName": "Type",
            "label": "Type",
            "lookupId": null,
            "sortable": true
        },
        {
            "fieldApiName": "Owner.Alias",
            "label": "Account Owner Alias",
            "lookupId": "Owner.Id",
            "sortable": true
        }
    ],
    "eTag": "c1eaf36fd502359d11ff8342df52c6ab",
    "filterLogicString": null,
    "filteredByInfo": [],
    "label": "All Accounts",
    "listReference": {
        "id": "00B5i00000cCVbgEAG",
        "listViewApiName": "AllAccounts",
        "objectApiName": "Account",
        "type": "listView"
    },
    "orderedByInfo": [
        {
            "fieldApiName": "Name",
            "isAscending": true,
            "label": "Account Name"
        }
    ],
    "updateable": true,
    "userPreferences": {
        "columnWidths": {
            "Site": -1,
            "Type": -1,
            "Owner.Alias": -1,
            "Phone": -1,
            "BillingState": -1,
            "Name": -1
        },
        "columnWrap": {
            "Site": false,
            "Type": false,
            "Owner.Alias": false,
            "Phone": false,
            "BillingState": false,
            "Name": false
        }
    },
    "visibility": "Public",
    "visibilityEditable": true
}

ListViewのカラムは取得できている感じです。

image.png

検索条件、共有設定はないのかな。

Winter'15 ListView API を使用した Super ListView ビューア

古い記事ですが、REST APIがあるのかな?

{{_endpoint}}/services/data/v{{version}}/sobjects/:SOBJECT_API_NAME/listviews/

UI API と内容は似ているけどフォーマットは違う。

{
    "done": true,
    "listviews": [
        {
            "describeUrl": "/services/data/v60.0/sobjects/Account/listviews/00B5i00000cCVazEAG/describe",
            "developerName": "NewThisWeek",
            "id": "00B5i00000cCVazEAG",
            "label": "New This Week",
            "resultsUrl": "/services/data/v60.0/sobjects/Account/listviews/00B5i00000cCVazEAG/results",
            "soqlCompatible": true,
            "url": "/services/data/v60.0/sobjects/Account/listviews/00B5i00000cCVazEAG"
        },
        {
            "describeUrl": "/services/data/v60.0/sobjects/Account/listviews/00B5i00000cCVbAEAW/describe",
            "developerName": "NewLastWeek",
            "id": "00B5i00000cCVbAEAW",
            "label": "New Last Week",
            "resultsUrl": "/services/data/v60.0/sobjects/Account/listviews/00B5i00000cCVbAEAW/results",
            "soqlCompatible": true,
            "url": "/services/data/v60.0/sobjects/Account/listviews/00B5i00000cCVbAEAW"
        },
        {
            "describeUrl": "/services/data/v60.0/sobjects/Account/listviews/00B5i00000cCVbQEAW/describe",
            "developerName": "PlatinumandGoldSLACustomers",
            "id": "00B5i00000cCVbQEAW",
            "label": "Platinum and Gold SLA Customers",
            "resultsUrl": "/services/data/v60.0/sobjects/Account/listviews/00B5i00000cCVbQEAW/results",
            "soqlCompatible": true,
            "url": "/services/data/v60.0/sobjects/Account/listviews/00B5i00000cCVbQEAW"
        },
        {
            "describeUrl": "/services/data/v60.0/sobjects/Account/listviews/00B5i00000cCVbfEAG/describe",
            "developerName": "RecentlyViewedAccounts",
            "id": "00B5i00000cCVbfEAG",
            "label": "Recently Viewed Accounts",
            "resultsUrl": "/services/data/v60.0/sobjects/Account/listviews/00B5i00000cCVbfEAG/results",
            "soqlCompatible": true,
            "url": "/services/data/v60.0/sobjects/Account/listviews/00B5i00000cCVbfEAG"
        },
        {
            "describeUrl": "/services/data/v60.0/sobjects/Account/listviews/00B5i00000cCVbgEAG/describe",
            "developerName": "AllAccounts",
            "id": "00B5i00000cCVbgEAG",
            "label": "All Accounts",
            "resultsUrl": "/services/data/v60.0/sobjects/Account/listviews/00B5i00000cCVbgEAG/results",
            "soqlCompatible": true,
            "url": "/services/data/v60.0/sobjects/Account/listviews/00B5i00000cCVbgEAG"
        },
        {
            "describeUrl": "/services/data/v60.0/sobjects/Account/listviews/00B5i00000cCVbmEAG/describe",
            "developerName": "MyAccounts",
            "id": "00B5i00000cCVbmEAG",
            "label": "My Accounts",
            "resultsUrl": "/services/data/v60.0/sobjects/Account/listviews/00B5i00000cCVbmEAG/results",
            "soqlCompatible": true,
            "url": "/services/data/v60.0/sobjects/Account/listviews/00B5i00000cCVbmEAG"
        }
    ],
    "nextRecordsUrl": null,
    "size": 6,
    "sobjectType": "Account"
}

以下で、詳細を取ることができますが、共有設定はやっぱりないな。

{{_endpoint}}/services/data/v{{version}}/sobjects/:SOBJECT_API_NAME/listviews/:LIST_VIEW_ID/results

検索内容は取得できます。

    "query": "SELECT Name, Site, BillingState, Phone, toLabel(Type), Owner.Alias, Id, CreatedDate, LastModifiedDate, SystemModstamp, Owner.Id, OwnerId FROM Account USING SCOPE mru ORDER BY Name ASC NULLS FIRST, Id ASC NULLS FIRST",
    "relatedEntityId": null,
    "scope": "mru",
    "scopeEntityId": null,
    "sobjectType": "Account",
    "whereCondition": {
        "conditions": [],
        "conjunction": "and"

共有設定

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?