この文章は Salesforce 機械翻訳システムを使用して翻訳されました。詳細はこちらをご参照ください。
英語に切り替える

describeDataCategoryGroupStructures()

要求で指定されたオブジェクトで使用できるカテゴリグループとそのデータカテゴリ構造を返します。

構文

1DescribeDataCategoryGroupStructureResult[] = connection.
2describeDataCategoryGroupStructures()(DataCategoryGroupSObjectTypePair[] pairs, boolean topCategoriesOnly)

使用方法

特定のオブジェクトとカテゴリグループのペアについて表示可能なデータカテゴリ構造を取得するには、このコールを使用します。最初に describeDataCategoryGroups() コールを使用して、指定したオブジェクトで使用できるカテゴリグループを検索します。返されたリストから、オブジェクトとカテゴリグループのペアを選択し、describeDataCategoryGroupStructures() の入力として渡します。このコールでは、出力としてすべての表示可能なカテゴリとデータカテゴリ構造が返されます。データカテゴリとデータカテゴリの表示設定についての詳細は、Salesforce オンラインヘルプの「データカテゴリとは?」および「カテゴリグループ表示設定について」を参照してください。

サンプルコード —Java

このサンプルでは、sObject とデータカテゴリグループのペアを使用して、各ペアのデータカテゴリを取得する方法を示します。KnowledgeArticleVersion/Regions および Question/Regions という 2 つのペアを使用して describeDataCategoryGroupStructures() をコールし、このコールの結果を反復処理します。各結果の最上位のカテゴリ、つまり「すべて」を取得してから、第 1 レベルの子カテゴリを取得します。このサンプルでは、複数の子カテゴリを持つ Regions というデータカテゴリグループを設定して、ナレッジの記事および質問に関連付ける必要があります。または、他の名前を持つ組織の既存のデータカテゴリグループを使用する場合は、サンプルのデータカテゴリグループ名を置き換えることができます。

1public void describeDataCateogryGroupStructuresSample() {
2    try {
3        // Create the data category pairs
4        DataCategoryGroupSobjectTypePair pair1 = 
5            new DataCategoryGroupSobjectTypePair();
6        DataCategoryGroupSobjectTypePair pair2 = 
7            new DataCategoryGroupSobjectTypePair();
8        pair1.setSobject("KnowledgeArticleVersion");
9        pair1.setDataCategoryGroupName("Regions");
10        pair2.setSobject("Question");
11        pair2.setDataCategoryGroupName("Regions");
12        
13        DataCategoryGroupSobjectTypePair[] pairs = 
14            new DataCategoryGroupSobjectTypePair[] {
15                pair1, 
16                pair2
17            };
18
19        // Get the list of top level categories using the describe call
20        DescribeDataCategoryGroupStructureResult[] results =
21            connection.describeDataCategoryGroupStructures(
22                pairs,
23                false
24        );
25        
26        // Iterate through each result and get some properties
27        // including top categories and child categories
28        for (int i = 0; i < results.length; i++) {
29          DescribeDataCategoryGroupStructureResult result = 
30              results[i];
31          String sObject = result.getSobject();
32          System.out.println("sObject: " + sObject);
33          System.out.println("Group name: " + result.getName());
34          System.out.println("Group label: " + result.getLabel());
35          System.out.println("Group description: " + 
36              result.getDescription());
37          
38          // Get the top-level categories
39          DataCategory[] topCategories = result.getTopCategories();
40          
41          // Iterate through the top level categories and retrieve 
42          // some information
43          for (int j = 0; j < topCategories.length; j++) {
44            DataCategory topCategory = topCategories[j];
45            System.out.println("Category name: " + 
46                topCategory.getName());
47            System.out.println("Category label: " + 
48                topCategory.getLabel());
49            DataCategory [] childCategories =
50                topCategory.getChildCategories();
51            System.out.println("Child categories: ");
52            for (int k = 0; k < childCategories.length; k++) {
53              System.out.println("\t" + k + ". Category name: " +
54                  childCategories[k].getName());
55              System.out.println("\t" + k + ". Category label: " +
56                  childCategories[k].getLabel());
57            }
58          }
59        }
60      } catch (ConnectionException ce) {
61        ce.printStackTrace();
62    }
63}

サンプルコード —C#

このサンプルでは、sObject とデータカテゴリグループのペアを使用して、各ペアのデータカテゴリを取得する方法を示します。KnowledgeArticleVersion/Regions および Question/Regions という 2 つのペアを使用して describeDataCategoryGroupStructures() をコールし、このコールの結果を反復処理します。各結果の最上位のカテゴリ、つまり「すべて」を取得してから、第 1 レベルの子カテゴリを取得します。このサンプルでは、複数の子カテゴリを持つ Regions というデータカテゴリグループを設定して、ナレッジの記事および質問に関連付ける必要があります。または、他の名前を持つ組織の既存のデータカテゴリグループを使用する場合は、サンプルのデータカテゴリグループ名を置き換えることができます。

1public void describeDataCateogryGroupStructuresSample() {
2    try {
3        // Create the data category pairs
4        DataCategoryGroupSobjectTypePair pair1 = 
5            new DataCategoryGroupSobjectTypePair();
6        DataCategoryGroupSobjectTypePair pair2 = 
7            new DataCategoryGroupSobjectTypePair();
8        pair1.sobject = "KnowledgeArticleVersion";
9        //pair1.setDataCategoryGroupName("Regions");
10        pair1.dataCategoryGroupName = "KBArticleCategories";
11        pair2.sobject = "Question";
12        //pair2.setDataCategoryGroupName("Regions");
13        pair2.dataCategoryGroupName = "KBArticleCategories";
14            
15        DataCategoryGroupSobjectTypePair[] pairs = 
16            new DataCategoryGroupSobjectTypePair[] {
17                pair1, 
18                pair2
19            };
20
21        // Get the list of top level categories using the describe call
22        DescribeDataCategoryGroupStructureResult[] results =
23            binding.describeDataCategoryGroupStructures(
24                pairs,
25                false
26        );
27            
28        // Iterate through each result and get some properties
29        // including top categories and child categories
30        for (int i = 0; i < results.Length; i++) {
31            DescribeDataCategoryGroupStructureResult result = 
32                results[i];
33            String sObject = result.sobject;
34            Console.WriteLine("sObject: " + sObject);
35            Console.WriteLine("Group name: " + result.name);
36            Console.WriteLine("Group label: " + result.label);
37            Console.WriteLine("Group description: " + 
38                result.description);
39              
40            // Get the top-level categories
41            DataCategory[] topCategories = result.topCategories;
42              
43            // Iterate through the top level categories and retrieve 
44            // some information
45            for (int j = 0; j < topCategories.Length; j++) {
46            DataCategory topCategory = topCategories[j];
47            Console.WriteLine("Category name: " + 
48                topCategory.name);
49            Console.WriteLine("Category label: " + 
50                topCategory.label);
51            DataCategory [] childCategories =
52                topCategory.childCategories;
53            Console.WriteLine("Child categories: ");
54            for (int k = 0; k < childCategories.Length; k++) {
55                Console.WriteLine("\t" + k + ". Category name: " +
56                    childCategories[k].name);
57                Console.WriteLine("\t" + k + ". Category label: " +
58                    childCategories[k].label);
59            }
60            }
61        }
62    } 
63    catch (SoapException e) 
64    {
65        Console.WriteLine("An unexpected error has occurred: " +
66            e.Message + "\n" + e.StackTrace);
67    }
68}

引数

名前 説明
pairs DataCategoryGroupSObjectTypePair[] クエリ対象のカテゴリグループとオブジェクトを指定します。そのオブジェクトの表示可能なデータカテゴリが取得されます。
topCategoriesOnly boolean ユーザのデータカテゴリグループ表示設定に応じて、コールが表示可能な最上位カテゴリのみ (true) を返すか、またはすべてのカテゴリ (false) を返すかを指定します。データカテゴリグループ表示設定についての詳細は、Salesforce オンラインヘルプの「カテゴリグループ表示設定について」を参照してください。

DataCategoryGroupSObjectTypePair には次の項目が含まれます。

名前 説明
dataCategoryGroupName string データカテゴリグループへの API アクセスに使用される一意の名前。
sobject string データカテゴリグループに関連付けられたオブジェクト