LoginSignup
0
0

Tooling APIを使ってコンポーネントが使用されている場所の調査する

Last updated at Posted at 2024-02-19

Apex上でエンドポイントをべた書きするのではなく、以下の設定方法で動作しました。

①指定ログイン情報に
https://私のドメイン.my.salesforce.com/
ではなく
https://私のドメイン.my.salesforce.com/services/data/v60.0/tooling/query/
まで記載

②Apex上で
callout:指定ログイン情報名
でエンドポイントを設定したところ動作しました!

また、確認の中でToolingAPIに対してセッションIDは認証として関係無いという記事も見つけることが出来ました。

sapleAuraというコンポーネントのMetadataComponentIdが分かっていれば、依存関係を検索できるとは思います。

組織内のメタデータコンポーネント間の依存関係を表します。書き込みを実行できますメタデータコンポーネントの依存関係API バージョン 43.0 以降の Tooling API を使用するか、API 49.0 以降の Bulk API 2.0 を使用します。

メタデータコンポーネントの依存関係(ベータ)

Postmanを使ってMetadataComponentIdが検索できる。

以下のクエリで DeveloperName='toastTest' 太字のところを探したいコンポーネントにすれば検索できると思います。

select+Id,FullName,DeveloperName+from+AuraDefinitionBundle+where+DeveloperName='toastTest'

検索結果はこんな感じです。このidを使えばいいのかな?

{
    "size": 1,
    "totalSize": 1,
    "done": true,
    "queryLocator": null,
    "entityTypeName": "AuraDefinitionBundle",
    "records": [
        {
            "attributes": {
                "type": "AuraDefinitionBundle",
                "url": "/services/data/v59.0/tooling/sobjects/AuraDefinitionBundle/0Ab5i0000014DkdCAE"
            },
            "Id": "0Ab5i0000014DkdCAE",
            "FullName": "toastTest",
            "DeveloperName": "toastTest"
        }
    ]
}

実際にAuraコンポーネントをアクションのボタンにしているものを検索してみました。

ボタンと言うよりはアクションを設定しているオブジェクトが検索されていますね。

image.png

何故、LWCのコンポーネントはここで検索されないのかは私では分かりませんね。

ただ、興味深いことに同じようなことが質問されてました。
ベータ版なので完ぺきではないのかな?

@sfdcfox I managed to find the view, in which the component was previously used, via MetadataComponentDependency, and this salesforcecodex.com/salesforce/… My problem now is that I don't understand why that is the case? I pulled down the digital experience bundle, and looked though the view, but cannot find the property i want to delete. It does not exist? so why does it show up as a dependcy?

今回使ったクエリの覚え

select+Id,FullName,DeveloperName+from+AuraDefinitionBundle+where+DeveloperName='fkd_kenmei_Action'
SELECT+MetadataComponentName,MetadataComponentType,RefMetadataComponentName,RefMetadataComponentType+FROM+MetadataComponentDependency+Where+MetadataComponentId='0Ab10000000HLIUCA4'
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