Power Platform でカタログに関するデータを取得する
テナントのカタログに関するデータを取得するには、どの環境にカタログがインストールされているのかを判断する必要があります。 次に、この情報を提供するように設計されたテーブルまたはAPIをクエリすることで、カタログに関する 環境 からデータを取得できます。
ほとんどのテナントではカタログを1つだけインストールしますが、テナント内の複数の環境にカタログをインストールすることも可能です。
テナント内のカタログを含む環境を検索する
テナント内のカタログを含む環境を表示するには、 pac admin list コマンドを使用します。
ヒント
このコマンドには、管理者の認証プロファイルが必要です。
このコマンドを使用する場合、次の --application
パラメータを値 83a35943-cb41-4266-b7d2-81d60f383695
で使用する必要があります。 この値は、カタログに関連付けられたアプリケーションIDです。
PS C:\Users\you> pac admin list --application 83a35943-cb41-4266-b7d2-81d60f383695
Connected as you@yourorg.onmicrosoft.com
Listing all environments from your tenant...
Active Environment Environment ID Environment Url Type Organization ID
* Your Org b16bdb7a-e023-4158-a839-4f8831ed2432 https://yourorg.crm.dynamics.com/ Production e20be4c1-02ce-4e81-93c6-6e95ff053943
カタログ テーブル
テナント内の 環境 にカタログ マネージャー アプリケーションを インストール Power Platform すると、 カタログの テーブル/エンティティ参照 Power Platform にリストされているテーブルがその 環境 にのみ追加されます。
使用する可能性のある最も重要なテーブルの一部を次の表に示します。
テーブル | プロパティ |
---|---|
承認リクエスト (mspcat_certificationrequest) | カタログ システムへの新規または更新済みの送信を処理する際に使用する、承認レコードを含みます。 |
カタログ発行者 (mspcat_publisher) | TPSパブリッシャー データを保持するためのパブリッシャー エンティティ。 |
カタログ項目 (mspcat_applications) | カタログに表示されるエントリ |
パッケージ (mspcat_packages) | カタログ品目の展開資産。 |
インストール履歴 (mspcat_InstallHistory) | インストールとその状態のレコードを含みます |
インストール アクティビティ (mspcat_InstallActivity) | インストール履歴アクティビティID |
カタログ情報を見る
カタログに関する情報を取得するために使用できる Dataverse メッセージは 2 つあります。
mspcat_GetPowerCatalogInformation
このメッセージは高速であり、カタログの最小限の権限と説明データを提供することを目的としています。mspcat_GetPowerCatalogDetails
このメッセージの内容を使用して、送信ドキュメントを入力し、このカタログでカタログ アイテムと発行元を参照するためのラベルを設定します。
mspcat_GetPowerCatalogInformation
メッセージには1つの ブール値 パラメータがあり、複合型で定義された次の情報を返します。 mspcat_GetPowerCatalogInformation
permissionsonly
mspcat_GetPowerCatalogInformationResponse
件名 | タイプ | プロパティ |
---|---|---|
SolutionVersion |
string | インストールされたカタログ ソリューションのバージョン |
CatalogDescription |
string | このカタログの目的を説明します |
CanRead |
ブール値 | ユーザーによるカタログ項目の読み取りの可否 |
CatalogName |
string | これにインストールされているカタログの名前 環境 |
ImageLink |
string | 設定する場合は、カタログの画像を選択します |
CanSubmit |
ブール値 | ユーザーによるカタログへの項目の送信の可否 |
permissionsonly
ブール値 パラメータがtrueの場合、 CatalogDescription
、 CatalogName
、および ImageLink
の値は返されません。 SolutionVersion
、 CanRead
、および CanSubmit
の値は常に返されます。
次の GetPowerCatalogInformationExample
静的メソッドは、pac modelbuilder build コマンドによって mspcat_GetPowerCatalogInformation
メッセージ用に生成された mspcat_GetPowerCatalogInformationRequest
および mspcat_GetPowerCatalogInformationResponse
クラスを使用してデータを取得します。
/// <summary>
/// Returns data about the catalog for an environment
/// </summary>
/// <param name="service">The authenticated IOrganizationService instance.</param>
/// <param name="permissionsonly">Whether to only return information about permissions.</param>
static void GetPowerCatalogInformationExample(IOrganizationService service, bool permissionsonly = false)
{
var request = new mspcat_GetPowerCatalogInformationRequest();
if (permissionsonly) {
request.permissionsonly = true;
}
var response = (mspcat_GetPowerCatalogInformationResponse)service.Execute(request);
Console.WriteLine($"SolutionVersion: {response.SolutionVersion}");
Console.WriteLine($"CatalogDescription: {response.CatalogDescription}");
Console.WriteLine($"CanRead: {response.CanRead}");
Console.WriteLine($"CatalogName: {response.CatalogName}");
Console.WriteLine($"ImageLink: {response.ImageLink}");
Console.WriteLine($"CanSubmit: {response.CanSubmit}");
}
Output
permissionsonly
は偽に等しい。
SolutionVersion: 1.1.24.500
CatalogDescription: Catalog in Power Platform applications created by your company.
CanRead: True
CatalogName: Default Catalog Name
ImageLink:
CanSubmit: True
mspcat_GetPowerCatalogDetails
mspcat_GetPowerCatalogDetails
によって返された情報を使用して、送信ドキュメントを入力し、このカタログでカタログ アイテムと発行元を参照するためのラベルを設定します。
この関数は、エンコードされた文字列を含む単一の CatalogDetails
文字列プロパティを持つオブジェクトを返します。 デコードされると、文字列には次のプロパティを持つJSONデータが含まれます。
件名 | タイプ | プロパティ |
---|---|---|
catalogId |
string | カタログの一意 ID |
isSuccess |
string | 内部でのみ使用します。 |
sourceOptions |
オプション配列 | mspcat_certificationrequest_requestsource グローバル選択からのオプション。 |
categoryOptions |
オプション配列 | mspcat_catalogbusinesscategory グローバル選択からのオプション。 |
publisherLocalizedDisplayName |
string | カタログ発行元のローカライズされた名前。 |
catalogItemLocalizedDisplayName |
string | カタログ項目を参照するために使用されるローカライズされた名前。 |
次の GetPowerCatalogDetailsExample
静的メソッドは、pac modelbuilder build コマンドによって mspcat_GetPowerCatalogDetails
メッセージ用に生成された mspcat_GetPowerCatalogDetailsRequest
および mspcat_GetPowerCatalogDetailsResponse
クラスを使用してデータを取得します。
/// <summary>
/// Outputs details of the catalog in Power Platform.
/// </summary>
/// <param name="service">The authenticated IOrganizationService instance.</param>
static void GetPowerCatalogDetailsExample(IOrganizationService service) {
var request = new mspcat_GetPowerCatalogDetailsRequest();
var response = (mspcat_GetPowerCatalogDetailsResponse)service.Execute(request);
JsonDocument catalogDetails = JsonDocument.Parse(response.CatalogDetails);
string catalogId = catalogDetails.RootElement.GetProperty("catalogId").GetString();
bool isSuccess = catalogDetails.RootElement.GetProperty("isSuccess").GetBoolean();
JsonElement sourceOptions = catalogDetails.RootElement.GetProperty("sourceOptions");
JsonElement categoryOptions = catalogDetails.RootElement.GetProperty("categoryOptions");
string publisherLocalizedDisplayName = catalogDetails.RootElement.GetProperty("publisherLocalizedDisplayName").GetString();
string catalogItemLocalizedDisplayName = catalogDetails.RootElement.GetProperty("catalogItemLocalizedDisplayName").GetString();
Console.WriteLine($"catalogId: {catalogId}");
Console.WriteLine($"isSuccess: {isSuccess}");
Console.WriteLine("sourceOptions:");
foreach (JsonElement element in sourceOptions.EnumerateArray())
{
int id = element.GetProperty("id").GetInt32();
string label = element.GetProperty("userLocalziedLabel").GetString();
Console.WriteLine($" {id} {label}");
}
Console.WriteLine("categoryOptions:");
foreach (JsonElement element in categoryOptions.EnumerateArray())
{
int id = element.GetProperty("id").GetInt32();
string label = element.GetProperty("userLocalziedLabel").GetString();
Console.WriteLine($" {id} {label}");
}
Console.WriteLine($"publisherLocalizedDisplayName: {publisherLocalizedDisplayName}");
Console.WriteLine($"catalogItemLocalizedDisplayName: {catalogItemLocalizedDisplayName}");
}
Output
static GetPowerCatalogDetailsExample
メソッドは、次のような内容をコンソールに書き込みます。
catalogId: 883278f5-07af-45eb-a0bc-3fea67caa544
isSuccess: True
sourceOptions:
526430000 Other
526430001 Power Automate Maker Portal
526430002 Power Platform Maker Portal
526430003 Power Virtual Agents Maker Portal
526430004 Power Platform Admin API
526430005 PAC CLI
526430006 PAC Build Task
526430007 Pipelines in Power Platform
categoryOptions:
526430000 Customer Service
526430001 Project Management
526430002 Calendar Management & Scheduling
526430003 Email Management
526430004 Files & Documentation
526430005 Notification & Reminders
526430006 Analytics
526430007 Collaboration
526430008 Commerce
526430009 Finance
526430010 Compliance & Legal
526430011 Sales
526430012 IT Tools
526430013 Marketing
526430014 Operations & Supply Chain
526430015 Internet of Things
526430016 AI Machine Learning
526430017 Geolocation
526430018 Human Resources
publisherLocalizedDisplayName: Catalog Publisher
catalogItemLocalizedDisplayName: Catalog Item
カタログでアイテムを表示する
PAC CLIを使用するか、 カタログ項目 (mspcat_applications) テーブルを照会することで、カタログ内の項目を検出できます。
PAC CLI の使用
カタログ内のアイテムを表示するには、pac category list コマンドを使用します。
pac catalog list
Connected to... TestCatalog
Connected as user@domain
Listing all published catalog items from the current Dataverse Organization...
Catalog Item Name Publisher Name Catalog Item Id Revision Id Version Status
Contoso Conference Custom Connector Catalog Conferences Team ContosoConferencesCustomConnector 4e882dd6-74f3-ed11-8849-000d3a0a286b 1.0.0.1 Published
Contoso Themed Components ContosoPublisher ContosoThemedComponents efbc469d-f1b2-ed11-83fd-000d3a0a2d9d 1.0.0.1 Published
次のパラメータを使用して、返されるレコードをフィルタリングすることもできます。
パラメーター | エイリアス | プロパティ |
---|---|---|
--catalog-item-id |
-cid |
検索するカタログ品目 ID。 カタログアイテムIDを使用すると、 --catalog-item-name パラメータ値は無視されます。 |
--catalog-item-name |
-n |
検索する Catalog 品目名です。 |
--include-active |
-ia |
アクティブな品目を含めます。 |
--json
パラメータを使用して JSON データを返すようにします。
別の 環境 内のカタログを照会するには、 --environment
(-env
) パラメータを使用します。
Dataverse テーブルをクエリする
カタログ項目に関する情報は、 カタログ項目 (mspcat_applications) テーブルに格納されているため、他の Dataverse テーブルと同様にデータを取得できます。
次の静的 RetrieveCatalogItems
算出方法は、カタログ アイテム (mspcat_applications) と パッケージ (mspcat_packages) テーブルからカタログ内のアイテムに関するデータ テーブルを取得して出力します。 この関数は、コンソール アプリケーションでテーブルをレンダリングするために、 ConsoleTables NuGet パッケージ に依存します。
/// <summary>
/// Retrieves information about catalog items and writes it to the console
/// </summary>
/// <param name="service">The authenticated IOrganizationService instance.</param>
static void RetrieveCatalogItems(IOrganizationService service)
{
QueryExpression query = new("mspcat_applications")
{
ColumnSet = new ColumnSet(
"mspcat_tpsid",
"mspcat_deploytype",
"mspcat_applicationtype",
"mspcat_businesscategory",
"mspcat_description",
"mspcat_applicationsid",
"mspcat_publisherid",
"mspcat_name",
"statuscode"),
Criteria = new FilterExpression(LogicalOperator.And)
{
Conditions = {
{
new ConditionExpression(
attributeName: "statecode",
conditionOperator: ConditionOperator.Equal,
value: 0)
}
}
}
};
LinkEntity linkToPackages = query.AddLink(
linkToEntityName: "mspcat_packages",
linkFromAttributeName: "mspcat_packageasset",
linkToAttributeName: "mspcat_packagesid",
joinOperator: JoinOperator.Inner);
linkToPackages.Columns = new ColumnSet(
"statecode",
"mspcat_uniquename",
"mspcat_version",
"statuscode");
linkToPackages.EntityAlias = "pkg";
EntityCollection catalogs = service.RetrieveMultiple(query);
var table = new ConsoleTables.ConsoleTable(
"Catalog Item Name",
"Publisher Name",
"Catalog Item ID",
"Revision ID",
"Version",
"Status");
foreach (Entity catalog in catalogs.Entities)
{
string catalogItemName = catalog.GetAttributeValue<string>("mspcat_name");
string publisherName = catalog.FormattedValues["mspcat_publisherid"];
string catalogItemId = catalog.GetAttributeValue<string>("mspcat_tpsid");
Guid revisionId = catalog.GetAttributeValue<Guid>("mspcat_applicationsid");
string version = (string)catalog.GetAttributeValue<AliasedValue>("pkg.mspcat_version").Value;
string status = catalog.FormattedValues["statuscode"];
string[] rowData = {
catalogItemName,
publisherName,
catalogItemId,
revisionId.ToString(),
version,
status
};
table.Rows.Add(rowData);
}
table.Write();
}
この例の出力は次のようになります。
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
| Catalog Item Name | Publisher Name | Catalog Item ID | Revision ID | Version | Status |
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
| Contoso Conference Custom Connector| Catalog Conferences Team| ContosoConferencesCustomConnector | 4e882dd6-74f3-ed11-8849-000d3a0a286b | 1.0.0.1 | Published |
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
| Contoso Themed Components | ContosoPublisher | ContosoThemedComponents | efbc469d-f1b2-ed11-83fd-000d3a0a2d9d | 1.0.0.1 | Published |
-----------------------------------------------------------------------------------------------------------------------------------------------------------------