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

ラッパー Aura コンポーネントでのフロー出力変数値の参照

Aura コンポーネントにフローを埋め込むときに、フローの変数値を表示または参照できます。フローの出力変数から値を取得するには、onstatuschange アクションを使用します。出力変数は配列として返されます。

変数で出力アクセスが許可されている必要があります。出力アクセスを許可しない変数を参照している場合、その変数を取得しようとしても無視されます。

メモ

次の例では、JavaScript コントローラを使用して、フローの accountName および numberOfEmployees 変数をコンポーネントの属性に渡します。次に、コンポーネントにより、これらの値が出力コンポーネントに表示されます。

1<aura:component>
2   <aura:attribute name="accountName" type="String" />
3   <aura:attribute name="numberOfEmployees" type="Decimal" />
4                            
5   <p><lightning:formattedText value="{!v.accountName}" /></p>
6   <p><lightning:formattedNumber style="decimal" value="{!v.numberOfEmployees}" /></p>
7                                
8   <aura:handler name="init" value="{!this}" action="{!c.init}"/>
9   <lightning:flow aura:id="flowData" onstatuschange="{!c.handleStatusChange}" />
10</aura:component>
1({
2   init : function (component) {
3      // Find the component whose aura:id is "flowData"
4      var flow = component.find("flowData");
5      // In that component, start your flow. Reference the flow's API Name.
6      flow.startFlow("myFlow");
7   },
8                                
9   handleStatusChange : function (component, event) {
10      if(event.getParam("status") === "FINISHED") {
11         // Get the output variables and iterate over them
12         var outputVariables = event.getParam("outputVariables");
13         var outputVar;
14         for(var i = 0; i < outputVariables.length; i++) {
15            outputVar = outputVariables[i];
16            // Pass the values to the component's attributes
17            if(outputVar.name === "accountName") {
18               component.set("v.accountName", outputVar.value);
19            } else {
20               component.set("v.numberOfEmployees", outputVar.value);
21            }
22         }
23      }
24   },
25})