Vlocity Facts #56 || Different Ways to Call Apex Class in DataMappers

If we need to call a apex class from omnistudio we need to follow these steps

  • Apex Class should be global with sharing to follow all the sharing settings.
  • The Apex Class must implement the Callable or PackageName.VlocityOpenInterface,[vlocity_cmt.VlocityOpenInterface] interface.
  • You must override the invokeMethod, which takes the following parameters
  1.  String methodName
  2.  Map<String, Object> input
  3.  Map<String, Object> output
  4.  Map<String, Object> option
Create apex class with above details 

Now we can call this apex class in 2 ways in DataMapper
  1. We can call this apex in DataMapper by using FUNCTION()
                FUNCTION('apexClassName','methodName',%Input%)
  2. This approach we can do if we are having the vlocity_cmt package or managed package.
We can create a custom metadata record from Setup -> Custom metadata -> search for "Function Definition" and click on "Manage Function Definitions" 
    • Create new record in "Function Definition" by populating the below details  

      In ClassName :- Populate the apex class
      In Method Name :- Populate the method name
and save the record, Now we can use the Function Definition Name -> "CalculateDateTime" in formula tab of the DataMapper by calling Name and pass the input parameters

Like this we can call the apex class in DataMapper.
---------------------------------------------------------------------------------------------------------
Note: Second approach will work only in Vlocity packages 



Comments

Popular posts from this blog

Vlocity Facts #01 | OmniStudio DataRaptors

Vlocity Facts #44 || Communication between Omniscript and Flexcard [Pub/Sub]

Vlocity Facts #39 || DataMapper - Functions and Formulas