ActionLinks クラス
名前空間
使用方法
アクションリンクは、フィード要素上のボタンです。アクションリンクをクリックすると、ユーザを特定の Web ページに移動したり、ファイルダウンロードを開始したり、Salesforce または外部サーバへの API コールを呼び出したりできます。アクションリンクには、URL と HTTP メソッドが含まれ、リクエストボディとヘッダー情報 (認証用の OAuth トークンなど) を含めることができます。アクションリンクを使用して Salesforce およびサードパーティサービスをフィードに統合することで、ユーザはアクションを実行して生産性を高め、イノベーションを促進できます。
アクションリンクとアクションリンクグループには、定義ビューとコンテキストユーザビューという 2 つのビューがあります。定義には、認証情報などの機密情報が含まれる可能性があります。コンテキストユーザビューは、表示オプションによって絞り込まれ、コンテキストユーザの状態が値に反映されます。
アクションリンクの使用方法については、「アクションリンクの使用」を参照してください。
ActionLinks のメソッド
ActionLinks のメソッドは次のとおりです。すべてのメソッドが静的です。
createActionLinkGroupDefinition(communityId, actionLinkGroup)
API バージョン
33.0
Chatter が必要かどうか
いいえ
署名
public static ConnectApi.ActionLinkGroupDefinition createActionLinkGroupDefinition(String communityId, ConnectApi.ActionLinkGroupDefinitionInput actionLinkGroup)
パラメータ
- communityId
- 型: String
- Experience Cloud サイトの ID、internal、または null を使用します。
- actionLinkGroup
- 型: ConnectApi.ActionLinkGroupDefinitionInput
- アクションリンクグループを定義する ConnectApi.ActionLinkGroupDefinitionInput オブジェクト。
使用方法
アクションリンクは、フィード要素上のボタンです。アクションリンクをクリックすると、ユーザを特定の Web ページに移動したり、ファイルダウンロードを開始したり、Salesforce または外部サーバへの API コールを呼び出したりできます。アクションリンクには、URL と HTTP メソッドが含まれ、リクエストボディとヘッダー情報 (認証用の OAuth トークンなど) を含めることができます。アクションリンクを使用して Salesforce およびサードパーティサービスをフィードに統合することで、ユーザはアクションを実行して生産性を高め、イノベーションを促進できます。
すべてのアクションリンクはグループに属している必要があります。1 つのグループ内のアクションリンクは、相互排他的で、同じプロパティを共有します。各自のアクショングループでスタンドアロンアクションを定義します。
アクションリンクグループ定義の情報は、サードパーティの機密情報である可能性があります (OAuth ベアラートークンヘッダーなど)。そのため、アクションリンクグループ定義を作成した Apex 名前空間からのコールでのみ定義を参照、変更、または削除できます。さらに、コールを実行するユーザは、定義を作成したユーザか、「すべてのデータの参照」権限を持つユーザである必要があります。
アクションリンクの定義、およびフィード要素を使用した投稿の例
1ConnectApi.ActionLinkGroupDefinitionInput actionLinkGroupDefinitionInput = new ConnectApi.ActionLinkGroupDefinitionInput();
2ConnectApi.ActionLinkDefinitionInput actionLinkDefinitionInput = new ConnectApi.ActionLinkDefinitionInput();
3ConnectApi.RequestHeaderInput requestHeaderInput1 = new ConnectApi.RequestHeaderInput();
4ConnectApi.RequestHeaderInput requestHeaderInput2 = new ConnectApi.RequestHeaderInput();
5
6// Create the action link group definition.
7actionLinkGroupDefinitionInput.actionLinks = New List<ConnectApi.ActionLinkDefinitionInput>();
8actionLinkGroupDefinitionInput.executionsAllowed = ConnectApi.ActionLinkExecutionsAllowed.OncePerUser;
9actionLinkGroupDefinitionInput.category = ConnectApi.PlatformActionGroupCategory.Primary;
10// To Do: Verify that the date is in the future.
11// Action link groups are removed from feed elements on the expiration date.
12datetime myDate = datetime.newInstance(2016, 3, 1);
13actionLinkGroupDefinitionInput.expirationDate = myDate;
14
15// Create the action link definition.
16actionLinkDefinitionInput.actionType = ConnectApi.ActionLinkType.Api;
17actionLinkDefinitionInput.actionUrl = '/services/data/v33.0/chatter/feed-elements';
18actionLinkDefinitionInput.headers = new List<ConnectApi.RequestHeaderInput>();
19actionLinkDefinitionInput.labelKey = 'Post';
20actionLinkDefinitionInput.method = ConnectApi.HttpRequestMethod.HttpPost;
21actionLinkDefinitionInput.requestBody = '{\"subjectId\": \"me\",\"feedElementType\": \"FeedItem\",\"body\": {\"messageSegments\": [{\"type\": \"Text\",\"text\": \"This is a test post created via an API action link.\"}]}}';
22actionLinkDefinitionInput.requiresConfirmation = true;
23
24// To Do: Substitute an OAuth value for your Salesforce org.
25requestHeaderInput1.name = 'Authorization';
26requestHeaderInput1.value = 'OAuth 00DD00000007WNP!ARsAQCwoeV0zzAV847FTl4zF.85w.EwsPbUgXR4SAjsp';
27actionLinkDefinitionInput.headers.add(requestHeaderInput1);
28
29requestHeaderInput2.name = 'Content-Type';
30requestHeaderInput2.value = 'application/json';
31actionLinkDefinitionInput.headers.add(requestHeaderInput2);
32
33// Add the action link definition to the action link group definition.
34actionLinkGroupDefinitionInput.actionLinks.add(actionLinkDefinitionInput);
35
36// Instantiate the action link group definition.
37ConnectApi.ActionLinkGroupDefinition actionLinkGroupDefinition = ConnectApi.ActionLinks.createActionLinkGroupDefinition(Network.getNetworkId(), actionLinkGroupDefinitionInput);
38
39ConnectApi.FeedItemInput feedItemInput = new ConnectApi.FeedItemInput();
40ConnectApi.FeedElementCapabilitiesInput feedElementCapabilitiesInput = new ConnectApi.FeedElementCapabilitiesInput();
41ConnectApi.AssociatedActionsCapabilityInput associatedActionsCapabilityInput = new ConnectApi.AssociatedActionsCapabilityInput();
42ConnectApi.MessageBodyInput messageBodyInput = new ConnectApi.MessageBodyInput();
43ConnectApi.TextSegmentInput textSegmentInput = new ConnectApi.TextSegmentInput();
44
45// Set the properties of the feedItemInput object.
46feedItemInput.body = messageBodyInput;
47feedItemInput.capabilities = feedElementCapabilitiesInput;
48feedItemInput.subjectId = 'me';
49
50// Create the text for the post.
51messageBodyInput.messageSegments = new List<ConnectApi.MessageSegmentInput>();
52textSegmentInput.text = 'Click to post a feed item.';
53messageBodyInput.messageSegments.add(textSegmentInput);
54
55
56// The feedElementCapabilitiesInput object holds the capabilities of the feed item.
57// Define an associated actions capability to hold the action link group.
58// The action link group ID is returned from the call to create the action link group definition.
59feedElementCapabilitiesInput.associatedActions = associatedActionsCapabilityInput;
60associatedActionsCapabilityInput.actionLinkGroupIds = new List<String>();
61associatedActionsCapabilityInput.actionLinkGroupIds.add(actionLinkGroupDefinition.id);
62
63// Post the feed item.
64ConnectApi.FeedElement feedElement = ConnectApi.ChatterFeeds.postFeedElement(Network.getNetworkId(), feedItemInput);テンプレートのアクションリンクの定義、およびフィード要素を使用した投稿の例
1// Get the action link group template Id.
2ActionLinkGroupTemplate template = [SELECT Id FROM ActionLinkGroupTemplate WHERE DeveloperName='Doc_Example'];
3
4// Add binding name-value pairs to a map.
5// The names are defined in the action link template(s) associated with the action link group template.
6// Get them from Setup UI or SOQL.
7Map<String, String> bindingMap = new Map<String, String>();
8bindingMap.put('ApiVersion', 'v33.0');
9bindingMap.put('Text', 'This post was created by an API action link.');
10bindingMap.put('SubjectId', 'me');
11
12// Create ActionLinkTemplateBindingInput objects from the map elements.
13List<ConnectApi.ActionLinkTemplateBindingInput> bindingInputs = new List<ConnectApi.ActionLinkTemplateBindingInput>();
14
15for (String key : bindingMap.keySet()) {
16 ConnectApi.ActionLinkTemplateBindingInput bindingInput = new ConnectApi.ActionLinkTemplateBindingInput();
17 bindingInput.key = key;
18 bindingInput.value = bindingMap.get(key);
19 bindingInputs.add(bindingInput);
20}
21
22// Set the template Id and template binding values in the action link group definition.
23ConnectApi.ActionLinkGroupDefinitionInput actionLinkGroupDefinitionInput = new ConnectApi.ActionLinkGroupDefinitionInput();
24actionLinkGroupDefinitionInput.templateId = template.id;
25actionLinkGroupDefinitionInput.templateBindings = bindingInputs;
26
27// Instantiate the action link group definition.
28ConnectApi.ActionLinkGroupDefinition actionLinkGroupDefinition =
29 ConnectApi.ActionLinks.createActionLinkGroupDefinition(Network.getNetworkId(), actionLinkGroupDefinitionInput);
30
31ConnectApi.FeedItemInput feedItemInput = new ConnectApi.FeedItemInput();
32ConnectApi.FeedElementCapabilitiesInput feedElementCapabilitiesInput = new ConnectApi.FeedElementCapabilitiesInput();
33ConnectApi.AssociatedActionsCapabilityInput associatedActionsCapabilityInput = new ConnectApi.AssociatedActionsCapabilityInput();
34ConnectApi.MessageBodyInput messageBodyInput = new ConnectApi.MessageBodyInput();
35ConnectApi.TextSegmentInput textSegmentInput = new ConnectApi.TextSegmentInput();
36
37// Define the FeedItemInput object to pass to postFeedElement
38feedItemInput.body = messageBodyInput;
39feedItemInput.capabilities = feedElementCapabilitiesInput;
40feedItemInput.subjectId = 'me';
41
42// The MessageBodyInput object holds the text in the post
43messageBodyInput.messageSegments = new List<ConnectApi.MessageSegmentInput>();
44
45textSegmentInput.text = 'Click to post a feed item.';
46messageBodyInput.messageSegments.add(textSegmentInput);
47
48
49// The FeedElementCapabilitiesInput object holds the capabilities of the feed item.
50// For this feed item, we define an associated actions capability to hold the action link group.
51// The action link group ID is returned from the call to create the action link group definition.
52feedElementCapabilitiesInput.associatedActions = associatedActionsCapabilityInput;
53associatedActionsCapabilityInput.actionLinkGroupIds = new List<String>();
54associatedActionsCapabilityInput.actionLinkGroupIds.add(actionLinkGroupDefinition.id);
55
56// Post the feed item.
57ConnectApi.FeedElement feedElement = ConnectApi.ChatterFeeds.postFeedElement(Network.getNetworkId(), feedItemInput);deleteActionLinkGroupDefinition(communityId, actionLinkGroupId)
API バージョン
33.0
Chatter が必要かどうか
いいえ
署名
public static void deleteActionLinkGroupDefinition(String communityId, String actionLinkGroupId)
パラメータ
戻り値
型: Void
使用方法
アクションリンクグループ定義の情報は、サードパーティの機密情報である可能性があります (OAuth ベアラートークンヘッダーなど)。そのため、アクションリンクグループ定義を作成した Apex 名前空間からのコールでのみ定義を参照、変更、または削除できます。さらに、コールを実行するユーザは、定義を作成したユーザか、「すべてのデータの参照」権限を持つユーザである必要があります。
getActionLink(communityId, actionLinkId)
API バージョン
33.0
Chatter が必要かどうか
いいえ
署名
public static ConnectApi.PlatformAction getActionLink(String communityId, String actionLinkId)
パラメータ
戻り値
getActionLinkDiagnosticInfo(communityId, actionLinkId)
API バージョン
33.0
Chatter が必要かどうか
いいえ
署名
public static ConnectApi.ActionLinkDiagnosticInfo getActionLinkDiagnosticInfo(String communityId, String actionLinkId)
パラメータ
getActionLinkGroup(communityId, actionLinkGroupId)
API バージョン
33.0
Chatter が必要かどうか
いいえ
署名
public static ConnectApi.PlatformActionGroup getActionLinkGroup(String communityId, String actionLinkGroupId)
パラメータ
使用方法
すべてのアクションリンクはグループに属している必要があります。1 つのグループ内のアクションリンクは、相互排他的で、同じプロパティを共有します。アクションリンクグループ定義とは異なり、アクションリンクグループは、クライアントからアクセスできます。
getActionLinkGroupDefinition(communityId, actionLinkGroupId)
API バージョン
33.0
Chatter が必要かどうか
いいえ
署名
public static ConnectApi.ActionLinkGroupDefinition getActionLinkGroupDefinition(String communityId, String actionLinkGroupId)
パラメータ
使用方法
アクションリンクグループ定義の情報は、サードパーティの機密情報である可能性があります (OAuth ベアラートークンヘッダーなど)。そのため、アクションリンクグループ定義を作成した Apex 名前空間からのコールでのみ定義を参照、変更、または削除できます。さらに、コールを実行するユーザは、定義を作成したユーザか、「すべてのデータの参照」権限を持つユーザである必要があります。