ディープリンクで LWC にデータを渡す
ディープリンクにより、データを Lightning Web コンポーネント (LWC) 間で渡すか、外部アプリケーションから LWC へ渡すことができます。LWC とディープリンクは、Android と iOS デバイスの Field Service Mobile アプリケーションで使用できます。
LWC フォームにデータを渡すなど、ディープリンクを使用してパラメーターを渡すには、クイックアクション URI スキーマを使用し、LWC クイックアクションを <api_name> として、その後にパラメーターのキーと値のペアを続けます。
1com.salesforce.fieldservice://v1/sObject/<id>/quickaction/<api_name>?<parameterKey1>=<parameterValue1>&<parameterKey2>=<parameterValue2>&...次に、LWC_Pass_Fields というクイックアクションを使用し、Jane Doe の姓と名を LWC に渡すディープリンク URL の例を示します。
1/quickaction/LWC_Pass_Fields?FirstName=Jane&LastName=Doeデータを渡すには、現在のページ参照 (ディープリンクが開く LWC) の LWC ソースコードも更新します。次に、パラメーター値を現在のページ参照の対応するパラメーターキーに渡す LWC の例を示します。
1import {CurrentPageReference} from 'lightning/navigation';
2
3// Declare the variable for the parameter value.
4parameterValue;
5
6// Call the page reference that describes the current LWC page.
7@wire(CurrentPageReference)
8setCurrentPageReference(currentPageReference) {
9 // Pass parameter values using the currentPageReference state attribute.
10 // Replace <parameterKey> with the parameter key name used in the deep link URL.
11 this.parameterValue = currentPageReference.state.<parameterKey>;
12}