describeDataCategoryGroupStructures()
要求で指定されたオブジェクトで使用できるカテゴリグループとそのデータカテゴリ構造を返します。
構文
1DescribeDataCategoryGroupStructureResult[] = connection.
2describeDataCategoryGroupStructures()(DataCategoryGroupSObjectTypePair[] pairs, boolean topCategoriesOnly)使用方法
特定のオブジェクトとカテゴリグループのペアについて表示可能なデータカテゴリ構造を取得するには、このコールを使用します。最初に describeDataCategoryGroups() コールを使用して、指定したオブジェクトで使用できるカテゴリグループを検索します。返されたリストから、オブジェクトとカテゴリグループのペアを選択し、describeDataCategoryGroupStructures() の入力として渡します。このコールでは、出力としてすべての表示可能なカテゴリとデータカテゴリ構造が返されます。データカテゴリとデータカテゴリの表示設定についての詳細は、Salesforce オンラインヘルプの「データカテゴリとは?」および「カテゴリグループ表示設定について」を参照してください。
サンプルコード —Java
このサンプルでは、sObject とデータカテゴリグループのペアを使用して、各ペアのデータカテゴリを取得する方法を示します。KnowledgeArticleVersion/Regions および Question/Regions という 2 つのペアを使用して describeDataCategoryGroupStructures() をコールし、このコールの結果を反復処理します。各結果の最上位のカテゴリ、つまり「すべて」を取得してから、第 1 レベルの子カテゴリを取得します。このサンプルでは、複数の子カテゴリを持つ Regions というデータカテゴリグループを設定して、ナレッジの記事および質問に関連付ける必要があります。または、他の名前を持つ組織の既存のデータカテゴリグループを使用する場合は、サンプルのデータカテゴリグループ名を置き換えることができます。
1swfobject.registerObject("clippy.codeblock-1", "9");
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17public void describeDataCateogryGroupStructuresSample() {
18 try {
19 // Create the data category pairs
20 DataCategoryGroupSobjectTypePair pair1 =
21 new DataCategoryGroupSobjectTypePair();
22 DataCategoryGroupSobjectTypePair pair2 =
23 new DataCategoryGroupSobjectTypePair();
24 pair1.setSobject("KnowledgeArticleVersion");
25 pair1.setDataCategoryGroupName("Regions");
26 pair2.setSobject("Question");
27 pair2.setDataCategoryGroupName("Regions");
28
29 DataCategoryGroupSobjectTypePair[] pairs =
30 new DataCategoryGroupSobjectTypePair[] {
31 pair1,
32 pair2
33 };
34
35 // Get the list of top level categories using the describe call
36 DescribeDataCategoryGroupStructureResult[] results =
37 connection.describeDataCategoryGroupStructures(
38 pairs,
39 false
40 );
41
42 // Iterate through each result and get some properties
43 // including top categories and child categories
44 for (int i = 0; i < results.length; i++) {
45 DescribeDataCategoryGroupStructureResult result =
46 results[i];
47 String sObject = result.getSobject();
48 System.out.println("sObject: " + sObject);
49 System.out.println("Group name: " + result.getName());
50 System.out.println("Group label: " + result.getLabel());
51 System.out.println("Group description: " +
52 result.getDescription());
53
54 // Get the top-level categories
55 DataCategory[] topCategories = result.getTopCategories();
56
57 // Iterate through the top level categories and retrieve
58 // some information
59 for (int j = 0; j < topCategories.length; j++) {
60 DataCategory topCategory = topCategories[j];
61 System.out.println("Category name: " +
62 topCategory.getName());
63 System.out.println("Category label: " +
64 topCategory.getLabel());
65 DataCategory [] childCategories =
66 topCategory.getChildCategories();
67 System.out.println("Child categories: ");
68 for (int k = 0; k < childCategories.length; k++) {
69 System.out.println("\t" + k + ". Category name: " +
70 childCategories[k].getName());
71 System.out.println("\t" + k + ". Category label: " +
72 childCategories[k].getLabel());
73 }
74 }
75 }
76 } catch (ConnectionException ce) {
77 ce.printStackTrace();
78 }
79}サンプルコード —C#
このサンプルでは、sObject とデータカテゴリグループのペアを使用して、各ペアのデータカテゴリを取得する方法を示します。KnowledgeArticleVersion/Regions および Question/Regions という 2 つのペアを使用して describeDataCategoryGroupStructures() をコールし、このコールの結果を反復処理します。各結果の最上位のカテゴリ、つまり「すべて」を取得してから、第 1 レベルの子カテゴリを取得します。このサンプルでは、複数の子カテゴリを持つ Regions というデータカテゴリグループを設定して、ナレッジの記事および質問に関連付ける必要があります。または、他の名前を持つ組織の既存のデータカテゴリグループを使用する場合は、サンプルのデータカテゴリグループ名を置き換えることができます。
1swfobject.registerObject("clippy.codeblock-2", "9");
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17public void describeDataCateogryGroupStructuresSample() {
18 try {
19 // Create the data category pairs
20 DataCategoryGroupSobjectTypePair pair1 =
21 new DataCategoryGroupSobjectTypePair();
22 DataCategoryGroupSobjectTypePair pair2 =
23 new DataCategoryGroupSobjectTypePair();
24 pair1.sobject = "KnowledgeArticleVersion";
25 //pair1.setDataCategoryGroupName("Regions");
26 pair1.dataCategoryGroupName = "KBArticleCategories";
27 pair2.sobject = "Question";
28 //pair2.setDataCategoryGroupName("Regions");
29 pair2.dataCategoryGroupName = "KBArticleCategories";
30
31 DataCategoryGroupSobjectTypePair[] pairs =
32 new DataCategoryGroupSobjectTypePair[] {
33 pair1,
34 pair2
35 };
36
37 // Get the list of top level categories using the describe call
38 DescribeDataCategoryGroupStructureResult[] results =
39 binding.describeDataCategoryGroupStructures(
40 pairs,
41 false
42 );
43
44 // Iterate through each result and get some properties
45 // including top categories and child categories
46 for (int i = 0; i < results.Length; i++) {
47 DescribeDataCategoryGroupStructureResult result =
48 results[i];
49 String sObject = result.sobject;
50 Console.WriteLine("sObject: " + sObject);
51 Console.WriteLine("Group name: " + result.name);
52 Console.WriteLine("Group label: " + result.label);
53 Console.WriteLine("Group description: " +
54 result.description);
55
56 // Get the top-level categories
57 DataCategory[] topCategories = result.topCategories;
58
59 // Iterate through the top level categories and retrieve
60 // some information
61 for (int j = 0; j < topCategories.Length; j++) {
62 DataCategory topCategory = topCategories[j];
63 Console.WriteLine("Category name: " +
64 topCategory.name);
65 Console.WriteLine("Category label: " +
66 topCategory.label);
67 DataCategory [] childCategories =
68 topCategory.childCategories;
69 Console.WriteLine("Child categories: ");
70 for (int k = 0; k < childCategories.Length; k++) {
71 Console.WriteLine("\t" + k + ". Category name: " +
72 childCategories[k].name);
73 Console.WriteLine("\t" + k + ". Category label: " +
74 childCategories[k].label);
75 }
76 }
77 }
78 }
79 catch (SoapException e)
80 {
81 Console.WriteLine("An unexpected error has occurred: " +
82 e.Message + "\n" + e.StackTrace);
83 }
84}引数
| 名前 | 型 | 説明 |
|---|---|---|
| pairs | DataCategoryGroupSObjectTypePair[] | クエリ対象のカテゴリグループとオブジェクトを指定します。そのオブジェクトの表示可能なデータカテゴリが取得されます。 |
| topCategoriesOnly | boolean | ユーザのデータカテゴリグループ表示設定に応じて、コールが表示可能な最上位カテゴリのみ (true) を返すか、またはすべてのカテゴリ (false) を返すかを指定します。データカテゴリグループ表示設定についての詳細は、Salesforce オンラインヘルプの「カテゴリグループ表示設定について」を参照してください。 |