Learn how to use Apex Remote from FlexCard and OmniScripts and what is required for the Apex class.
Sample code for the Apex Remote class can be found on github here.
To use Apex Remote, you need to define the class then you can select this as a Data Source type when creating a FlexCard or OmniScript.
Creating an Apex Remote Class For OmniStudio
First create an Apex Class that implements the VlocityOpenInterface.
Add the default implementation method invoke
Method Details
- methodName – name of the method to be called
- inputMap – key/value map passed to the class
- outMap – key/value map to return as part of the response
- options – key/value map
Create a try/catch that calls the method and returns the Boolean value
Next, create your method and set the outMap.
Using The Apex Remote From FlexCard
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 [“account”]
Add a Text Field to the Canvas and populate with the field results
Run the Preview and it should display the data.
Hope you like this post. I’ll be coming up with a newsletter soon to deliver the fresh tips and tricks.
[…] Check out this post for setting up the Apex Remote class – How to Setup Apex Remote with OmniStudio FlexCards […]
[…] and OmniScripts and what is required for the Apex class. On a previous post I covered using Apex Remote for FlexCards if that is what you are looking for go checkout that […]
How to pass RecordId in apex class from Flex card
check this new blog post. https://www.lopau.com/how-to-use-apex-remote-as-data-source-and-pass-the-recordid-from-flexcards/
[…] I wrote a post on how to use Apex Remote using FlexCards but that didn’t cover how you can pass the recordId. If you want to read that article you can […]
What are the scenarios where you would want to use Apex Remote in OmniStudio?
You can pretty much do the same with DR/IP. Just thinking of a scenario where there some complex queries that DR can’t do, option could be to use Apex to do that.
Hello,
How to write a test class for this can you explain?