How to call an Integration procedure from LWC

How to call an Integration procedure from LWC

Enable a custom Lightning web component to interact with OmniScript by extending the OmniScriptBaseMixin component. The OmniScriptBaseMixin includes methods to update OmniScript's data JSON, pass parameters, and more.

Steps to follow:

  • Import and extend OmniScriptBaseMixin in the LWC js.
  • import { OmniscriptBaseMixin } from 'NS/omniscriptBaseMixin';
  • runtimeNamespace: If Lightning Web Security (LWS) is disabled, add the namespace of your Vlocity package to the XML metadata file in your component by using the runtimeNamespace metadata tag.
  • <runtimeNamespace>NS<runtimeNamespace>
  • isExposed: Set the isExposed metadata tag to true.

In order to call the Integration Procedure the Custom LWCs extending the OmniScript Base Mixin must use the omniRemoteCall() function i.e., omniRemoteCall(params, boolean)

1. The first parameter of this method will be an object with the below properties:

  • input: Pass the JSON string needed for the Integration Procedure
  • sClassName: use the IntegrationProcedureService prefixed by the namespace
  • sMethodName: specify the name of the Integration Procedure in the format of type_subtype
  • options: set the optional parameters to enable jobs to be queuable, future, chainable, and continuable.

So, it should be framed like the below:

const params = {

	input: JSON.stringify(this.omniJsonData),

	sClassName: '{this._ns}IntegrationProcedureService',//Example:   sClassName:'omnistudio.IntegrationProcedureService',

	sMethodName: 'test_RemoteAction', //this will need to match the VIP -> type_subtype

	options: '{}',

};        


2. The second parameter of the omniRemoteCall function is an optional boolean value which will be passed to the omniSpinnerEnabled variable.

Example syntax to use the omniRemoteCall method:


this.omniRemoteCall(params, true).then(response => {

	window.console.log(response, 'response');

}).catch(error => {

	window.console.log(error, 'error');

});        

fter omniRemoteCall executes, the response callback returns an object containing the two properties' result and error.

  • result: The result property contains a raw response from the server.
  • error: The error property stores an error value from the Vlocity's GenericInvoke2 class.

Let's see the complete implementation in the below example:

const options = {

chainable: true, //Use chainable when an Integration Procedure exceeds the Salesforce CPU Governor limit.

useFuture: true,

};

const params = {

input: this.omniJsonDataStr,

sClassName: `${this._ns}IntegrationProcedureService`,

sMethodName: 'test_RemoteAction', //this will need to match the VIP -> type_subtype

options: JSON.stringify(options),

};        

要查看或添加评论,请登录

Silverline in India的更多文章

社区洞察

其他会员也浏览了