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
- String methodName
- Map<String, Object> input
- Map<String, Object> output
- Map<String, Object> option
Create apex class with above details
Now we can call this apex class in 2 ways in DataMapper
Now we can call this apex class in 2 ways in DataMapper
- We can call this apex in DataMapper by using FUNCTION()
FUNCTION('apexClassName','methodName',%Input%) - 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
Like this we can call the apex class in DataMapper.
---------------------------------------------------------------------------------------------------------
Note: Second approach will work only in Vlocity packages
Comments
Post a Comment