Remote actions call an Apex class from FlexCards, OmniScripts, or Integration Procedures.
Apex Class should be global with sharing to follow all the sharing settings.
Apex Class must implement the Callable interface, Only methods from classes that extend VlocityOpenInterface or VlocityOpenInterface2 can be invoked from a Vlocity Tool. In this class, you must override the invokeMethod, which takes the following parameters in order.
1. String methodName
2. Map<String, Object> input
3. Map<String, Object> output
4. Map<String, Object> option.
Try to use try and catch block
Then check the methodName and call that method by passing all the parameters except String methodName.
Here is a sample method that gets a list of Contacts
Create a Remote Action for an Integration Procedure.
From the OmniStudio Integration Procedures tab, click New.
Provide an Integration Procedure Name, a Type, and a SubType, and click Save.
Drag a Remote Action component into the Structure panel and give it these settings(without an input key):
Drag a Response Action into the Structure panel and check Return Full Data JSON.
Click Execute.
The above method can be invoked using the Remote Action and the results are as follows:
Create a Remote Action for a Flex Card.
Here is a sample method that gets a list of Accounts
Create a new FlexCard from OmniStudio FlexCard Designer
From the Data Wizard or the Setup Panel select Apex Remote as Data Source Type
Provide a Remote Class – AccountRemoteClass
Provide a Remote Method – getAccountRecords
Optionally provide Is Async and Poll Interval
Add InputMap or OptionsMap
Result JSON Path – set to [“result”]
Add a Text Field to the Canvas and populate with the field results
Run the Preview and it should display the data.
Create a Remote Action for an Omniscript.
Add a Remote Action before a Step, in a Step, or after a Step to load data or send data in the OmniScript. The OmniScript's data JSON is sent as the input.
In the Remote Class field, enter the name of the Apex class that the action calls.
In the Remote Method field, enter a method of the class that the Action calls.
Enter Remote Option Key/Value pairs.
(Optional) When Invoke Mode is set to non-blocking, elements using default values will not receive the response because the element loads before the response return. You must configure these properties to map the response to an element:
Response JSON Node: Particular node to Pass.
Response JSON Path: The name of the OmniScript Element receiving the value.