You are here:
Common Action Utility for Remote Calls (Managed Package)
For the managed package runtime, make remote calls from any custom LWC using the Common Action Utility. The Common Action Utility relies on the Vlocity Action Framework to make remote calls without the dependency of a strict Omniscript data structure.
This information is for Omnistudio for Managed Packages. For Omnistudio on standard runtime, see Omnistudio Help.
- Utility:
omniscriptActionUtils - Utility Class Name:
OmniscriptActionCommonUtil
Defined Methods and Available Variables (Managed Package)
For the managed package runtime, review the available methods and variables for remote calls.
This information is for Omnistudio for Managed Packages. For Omnistudio on standard runtime, see Omnistudio Help.
Method Name |
Description |
Argument - Data Type |
Returns |
|---|---|---|---|
executeAction |
Begins the execution of an action flow. |
|
promise |
handleActionEvents |
Handles action events once the remote call obtains a response. It can be configured to send events to the Omniscript Designer Debug console. Configured for sending pubsub events. In LWC, if sendDataToDebugConsole is defined in the component, event logs can be sent to the Debug Console in the Omniscript Designer. If the component is not in Omniscript, define _debugLabel in the component populate the debug log event name. If from omniscript, the debug log event name is populated from the label property in the element's property set. |
|
void |
invokeAction |
Method that invokes an Apex class or a Promise resolution using an action transformed request. |
|
promise |
postProcess |
Post-processes remote call response for both successful and failed remote calls and returns a post-processed response. The return contains an object with the key nodes:
|
|
object |
preProcess |
Preprocesses remote call parameters before invoking an action. |
|
object |
Variable Name |
Description |
|---|---|
_ns |
Namespace in dot notation |
_element |
(Optional) Omniscript element JSON definition |
Implementing the Common Action Utility (Managed Package)
For the managed package runtime, import the Common Action Utility into your Lightning Web component so that you can make remote calls.
This information is for Omnistudio for Managed Packages. For Omnistudio on standard runtime, see Omnistudio Help.
-
Obtain the dot notation format of the namespace in your LWC by importing
getNamespaceDotNotationfromomniscriptInternalUtils. Replace NS in the first line of code with the namespace of your package.NoteRemote calls made to Apex classes inside a vlocity managed package must include the namespace in the sClassName parameter sent into the
executeAction.import { getNamespaceDotNotation } from 'NS/omniscriptInternalUtils'; _ns = getNamespaceDotNotation(); -
Import
OmniscriptActionCommonUtilinto your LWC from the utility classomniscriptActionUtils. Replace NS in the first line of code with the namespace of your package.import { OmniscriptActionCommonUtil } from 'NS/omniscriptActionUtils'; -
Create an instance of the OmniscriptActionCommonUtil javascript class.
this._actionUtilClass = new OmniscriptActionCommonUtil(); -
Use the OmniscriptActionCommonUtil methods to execute remote calls to the server.
-
The most common flow is to use the
executeActionmethod. This method starts the remote call flow, and the response callback fromexecuteActionreturns an object that has these properties:-
result: Contains the response from the remote call.
-
error: Contains a boolean indicating the invoke status of GenericInvoke2.
-
-
Parameters sent into the
executeActionmust be in an object format. The object must have the following keys:-
input
-
sClassName
-
sMethodName
-
options
Each key requires a stringified value.
-
-
If the LWC displays in the Omniscript Designer, it is possible to send events to the Debug Console. Send events to the Debug Console by including the
sendDataToDebugConsolemethod in your LWC. The method provides logic on sending events to the Debug Console.sendDataToDebugConsoleaccepts these arguments:-
params
-
resp
-
label
-
-
- Sample remote call using
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); } - Sample queueable remote call
using 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'); }); } - Sample continuation remote call
using 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'); }); } - Sample future remote call
using 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'); }); } - Sample chainable remote call
using 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'); }); } - Sample parameters for a remote call from inside a Vlocity
package:
const params = { input: '{}', sClassName: `${this._ns}IntegrationProcedureService`, sMethodName: 'Test_Chainable', options: '{chainable: true}', };

