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

Lightning Experience のクイックアクション API

lightning:quickActionAPI コンポーネントでは、レコードページにあるクイックアクションをプログラムで制御するメソッドにアクセスできます。このコンポーネントは、Lightning Experience でサポートされ、ユーティリティのポップアップをサポートします。このコンポーネントでは、API バージョン 43.0 以降が必要です。
使用可能なインターフェース: Lightning Experience
使用可能なエディション: Group Edition、Professional Edition、Enterprise Edition、Performance Edition、Unlimited Edition、および Developer Edition

たとえば、ナレッジ記事を表示するカスタム Aura コンポーネントがある場合、lightning:quickActionAPI コンポーネントを使用して、ケースレコードページにあるメールクイックアクションでカスタムコンポーネントからナレッジ記事を添付および送信できます。

これらのメソッドにアクセスするには、Aura コンポーネントまたはページ内の lightning:quickActionAPI コンポーネントのインスタンスを作成し、aura:id 属性を割り当てます。

1<lightning:quickActionAPI aura:id="quickActionAPI"/>

このコンポーネントは、Salesforce Classic のパブリッシャー API に似た機能を提供します。

サンプルコード

この例では、Lightning Experience のケースレコードページにあるケースの更新クイックアクションを操作する 2 つのボタンを作成します。コントローラコードは、selectActionsetActionFieldValues、および invokeAction のクイックアクション API メソッドを使用します。

コンポーネントコード:

1<aura:component implements="flexipage:availableForRecordHome" description="My Lightning Component">
2    <lightning:quickActionAPI aura:id="quickActionAPI" />
3    <div>
4        <lightning:button label="Select Update Case Action" onclick="{!c.selectUpdateCaseAction}"/>
5        <lightning:button label="Update Case Status Field" onclick="{!c.updateCaseStatusAction}"/>
6    </div>
7</aura:component>

コントローラコード:

1({
2    selectUpdateCaseAction : function( cmp, event, helper) {
3        var actionAPI = cmp.find("quickActionAPI");
4        var args = { actionName :"Case.UpdateCase" };
5        actionAPI.selectAction(args).then(function(result) {
6            // Action selected; show data and set field values
7        }).catch(function(e) {
8            if (e.errors) {
9                // If the specified action isn't found on the page, 
10                // show an error message in the my component 
11            }
12        });
13    },
14    
15    updateCaseStatusAction : function( cmp, event, helper ) {
16        var actionAPI = cmp.find("quickActionAPI");
17        var fields = { Status : { value : "Closed"}, 
18                       Subject : { value : "Sets by lightning:quickActionAPI component" }, 
19                       accountName : { Id : "accountId" } };
20        var args = { actionName : "Case.UpdateCase", 
21                     entityName : "Case",
22                     targetFields : fields };
23        actionAPI.setActionFieldValues(args).then(function() {
24            actionAPI.invokeAction(args);
25        }).catch(function(e) {
26            console.error(e.errors);
27        });
28    }
29})