Newer Version Available
Schema メソッドを使用したタブの記述
Apex の記述用の API コール (describe) を実行することで、Salesforce ユーザインターフェースで使用できるアプリケーションとそのタブに関するメタデータ情報を取得できます。また、各タブに関する詳細情報も取得できます。この取得を実行できるメソッドは、それぞれ describeTabs Schema メソッドと Schema.DescribeTabResult の getTabs メソッドです。
この例では、各アプリケーションのタブセットを取得する方法を示します。次に、Sales アプリケーションのタブの Describe メタデータ情報を取得します。各タブのメタデータ情報には、アイコンの URL、タブがカスタムであるかどうか、色などが含まれます。タブの Describe 情報は、デバッグ出力に書き込まれます。
1swfobject.registerObject("clippy.codeblock-0", "9");
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17// Get tab set describes for each app
18List<Schema.DescribeTabSetResult> tabSetDesc = Schema.describeTabs();
19
20// Iterate through each tab set describe for each app and display the info
21for(DescribeTabSetResult tsr : tabSetDesc) {
22 String appLabel = tsr.getLabel();
23 System.debug('Label: ' + appLabel);
24 System.debug('Logo URL: ' + tsr.getLogoUrl());
25 System.debug('isSelected: ' + tsr.isSelected());
26 String ns = tsr.getNamespace();
27 if (ns == '') {
28 System.debug('The ' + appLabel + ' app has no namespace defined.');
29 }
30 else {
31 System.debug('Namespace: ' + ns);
32 }
33
34 // Display tab info for the Sales app
35 if (appLabel == 'Sales') {
36 List<Schema.DescribeTabResult> tabDesc = tsr.getTabs();
37 System.debug('-- Tab information for the Sales app --');
38 for(Schema.DescribeTabResult tr : tabDesc) {
39 System.debug('getLabel: ' + tr.getLabel());
40 System.debug('getColors: ' + tr.getColors());
41 System.debug('getIconUrl: ' + tr.getIconUrl());
42 System.debug('getIcons: ' + tr.getIcons());
43 System.debug('getMiniIconUrl: ' + tr.getMiniIconUrl());
44 System.debug('getSobjectName: ' + tr.getSobjectName());
45 System.debug('getUrl: ' + tr.getUrl());
46 System.debug('isCustom: ' + tr.isCustom());
47 }
48 }
49}
50// Example debug statement output
51// DEBUG|Label: Sales
52// DEBUG|Logo URL: https://na1.salesforce.com/img/seasonLogos/2014_winter_aloha.png
53// DEBUG|isSelected: true
54// DEBUG|The Sales app has no namespace defined.// DEBUG|-- Tab information for the Sales app --
55// (This is an example debug output for the Accounts tab.)
56// DEBUG|getLabel: Accounts
57// DEBUG|getColors: (Schema.DescribeColorResult[getColor=236FBD;getContext=primary;getTheme=theme4;],
58// Schema.DescribeColorResult[getColor=236FBD;getContext=primary;getTheme=theme3;],
59// Schema.DescribeColorResult[getColor=236FBD;getContext=primary;getTheme=theme2;])
60// DEBUG|getIconUrl: https://na1.salesforce.com/img/icon/accounts32.png
61// DEBUG|getIcons: (Schema.DescribeIconResult[getContentType=image/png;getHeight=32;getTheme=theme3;
62// getUrl=https://na1.salesforce.com/img/icon/accounts32.png;getWidth=32;],
63// Schema.DescribeIconResult[getContentType=image/png;getHeight=16;getTheme=theme3;
64// getUrl=https://na1.salesforce.com/img/icon/accounts16.png;getWidth=16;])
65// DEBUG|getMiniIconUrl: https://na1.salesforce.com/img/icon/accounts16.png
66// DEBUG|getSobjectName: Account
67// DEBUG|getUrl: https://na1.salesforce.com/001/o
68// DEBUG|isCustom: false