詳細情報:
リモート通話の共通アクションユーティリティ (管理パッケージ)
管理パッケージランタイムの場合、共通アクションユーティリティを使用してカスタム LWC からリモートコールを実行します。Common Action Utility は、Vlocity Action Framework を使用して、厳格な OmniScript データ構造に依存しないリモートコールを実行します。
この情報は、OmniStudio for Managed Packages 用です。標準ランタイムの OmniStudio については、OmniStudio ヘルプを参照してください。
- ユーティリティ:
omniscriptActionUtils - ユーティリティクラス名:
OmniscriptActionCommonUtil
定義済みメソッドと使用可能な変数 (管理パッケージ)
管理パッケージランタイムの場合、リモートコールで使用可能なメソッドと変数を確認します。
この情報は、OmniStudio for Managed Packages 用です。標準ランタイムの OmniStudio については、OmniStudio ヘルプを参照してください。
メソッド名 |
説明 |
引数 - データ型 |
戻り値 |
|---|---|---|---|
executeAction |
アクションフローの実行を開始します。 |
|
約束 |
handleActionEvents |
リモートコールが応答を取得したら、アクションイベントを処理します。OmniScript Designer のデバッグコンソールにイベントを送信するように設定できます。pubsub イベントを送信するように設定されます。 LWC では、コンポーネントで sendDataToDebugConsole が定義されている場合、OmniScript Designer のデバッグコンソールにイベントログを送信できます。コンポーネントが OmniScript にない場合は、コンポーネントで定義 _debugLabel を定義して、デバッグログイベント名を入力します。OmniScript からの場合、デバッグログイベント名は要素のプロパティセットの label プロパティから入力されます。 |
|
void |
invokeAction |
アクション変換要求を使用して Apex クラスまたは Promise 解決を呼び出すメソッド。 |
|
約束 |
postProcess |
成功したリモート通話と失敗したリモート通話の両方のリモート通話応答を後処理し、後処理された応答を返します。戻り値には、次のキーノードを持つオブジェクトが含まれます。
|
|
object |
preProcess |
アクションを呼び出す前にリモート通話パラメーターを前処理します。 |
|
object |
変数名 |
説明 |
|---|---|
_ns |
ドット表記の名前空間 |
_element |
(省略可能) OmniScript 要素の JSON 定義 |
Common Action Utility (管理パッケージ) の実装
管理パッケージランタイムの場合は、リモートコールを実行できるように Common Action Utility を Lightning Web コンポーネントにインポートします。
この情報は、OmniStudio for Managed Packages 用です。標準ランタイムの OmniStudio については、OmniStudio ヘルプを参照してください。
-
omniscriptInternalUtilsからgetNamespaceDotNotationをインポートして、LWC の名前空間のドット表記形式を取得します。コードの最初の行の NS をパッケージの名前空間に置き換えます。メモVlocity管理パッケージ内のApexクラスに対して実行されるリモート コールでは、
executeActionに送信されるsClassNameパラメーターに名前空間が含まれている必要があります。import { getNamespaceDotNotation } from 'NS/omniscriptInternalUtils'; _ns = getNamespaceDotNotation(); -
ユーティリティクラスから LWC
OmniscriptActionCommonUtilにインポートしますomniscriptActionUtils。コードの最初の行の NS をパッケージの名前空間に置き換えます。import { OmniscriptActionCommonUtil } from 'NS/omniscriptActionUtils'; -
OmniscriptActionCommonUtil javascript クラスのインスタンスを作成します。
this._actionUtilClass = new OmniscriptActionCommonUtil(); -
サーバーへのリモートコールを実行するには、 OmniscriptActionCommonUtil メソッド を使用します。
-
最も一般的なフローは、
executeActionメソッドを使用することです。このメソッドはリモート通話フローを開始し、executeActionからの応答コールバックは次のプロパティを持つオブジェクトを返します。-
result: リモート通話からの応答が含まれます。
-
error: GenericInvoke2 の呼び出し状況を示す Boolean が含まれます。
-
-
executeActionに送信されるパラメータは、オブジェクト形式である必要があります。オブジェクトには次のキーが必要です。-
input
-
sClassName
-
sMethodName
-
options
各キーには文字列値が必要です。
-
-
OmniScript Designer に LWC が表示されている場合、イベントをデバッグコンソールに送信できます。LWC に
sendDataToDebugConsoleメソッドを含めて、イベントをデバッグコンソールに送信します。このメソッドは、イベントをデバッグコンソールに送信するロジックを提供します。sendDataToDebugConsoleでは、次の引数を使用できます。-
params
-
resp
-
label
-
-
- executeAction を使用したリモートコールのサンプル:
connectedCallback() { this._actionUtilClass = new OmniscriptActionCommonUtil(); } triggerRemote() { const params = { input: '{}', sClassName: 'LwcTest', sMethodName: 'lwctest', options: '{}', }; this._actionUtilClass .executeAction(params, null, this, null, null) .then(response => { window.console.log(response); }) .catch(error => { window.console.log(error); }); } - Sample sendDataToDebugConsole method:
sendDataToDebugConsole(params, resp, label) { let sendParams = JSON.parse(JSON.stringify(params)); if (sendParams && sendParams.options) { let optionNode = JSON.parse(sendParams.options); delete optionNode.options; delete optionNode.input; sendParams.options = optionNode; } let sendResp = JSON.parse(JSON.stringify(resp)); // for queueable support if (sendResp && sendResp.responseResult) { sendResp.responseResult = JSON.parse(sendResp.responseResult); } // dispatches action data to debug console const debugEvent = new CustomEvent('omniactiondebug', { bubbles: true, cancelable: true, composed: true, detail: { params: sendParams, response: sendResp, element: { label: label }, }, }); this.dispatchEvent(debugEvent); } - executeAction を使用したキュー可能なリモートコールのサンプル:
connectedCallback() { this._actionUtilClass = new OmniscriptActionCommonUtil(); } triggerQueueable() { const options = { input: '{}', vlcClass: 'LwcTest', vlcMethod: 'lwctest', useQueueableApexRemoting: true, }; const params = { input: '{}', sClassName: `${this._ns}VFActionFunctionController.VFActionFunctionControllerOpen`, sMethodName: 'runActionFunction', options: JSON.stringify(options), }; this._actionUtilClass .executeAction(params, null, this, null, null) .then(response => { window.console.log(response); }) .catch(error => { window.console.log(error, 'error'); }); } - executeAction を使用した継続リモートコールのサンプル:
connectedCallback() { this._actionUtilClass = new OmniscriptActionCommonUtil(); } triggerContinuation() { const options = { input: '{}', vlcClass: 'QeRemoteAction2', vlcMethod: 'populateElements', useContinuation: true, }; const params = { input: JSON.stringify(this.omniJsonData), sClassName: 'QeRemoteAction2', sMethodName: 'populateElements', options: JSON.stringify(options), }; this._actionUtilClass .executeAction(params, null, this, null, null) .then(response => { window.console.log(response); }) .catch(error => { window.console.log(error, 'error'); }); } - 今後、 executeAction を使用したリモートコールのサンプル:
connectedCallback() { this._actionUtilClass = new OmniscriptActionCommonUtil(); } triggerFuture() { const options = { useFuture: true, }; const params = { input: '{}', sClassName: `${this._ns}IntegrationProcedureService`, sMethodName: 'Test_Chainable', options: JSON.stringify(options), }; this._actionUtilClass .executeAction(params, null, this, null, null) .then(response => { window.console.log(response); }) .catch(error => { window.console.log(error, 'error'); }); } - executeAction を使用したチェーン可能なリモートコールのサンプル:
connectedCallback() { this._actionUtilClass = new OmniscriptActionCommonUtil(); } triggerChainable() { const options = { chainable: true, }; const params = { input: '{}', sClassName: `${this._ns}IntegrationProcedureService`, sMethodName: 'Test_Chainable', options: JSON.stringify(options), }; this._actionUtilClass .executeAction(params, null, this, null, null) .then(response => { window.console.log(response); }) .catch(error => { window.console.log(error, 'error'); }); } - Vlocity パッケージ内からのリモート通話のサンプルパラメーターは次のとおりです。
const params = { input: '{}', sClassName: `${this._ns}IntegrationProcedureService`, sMethodName: 'Test_Chainable', options: '{chainable: true}', };
