Loading
Salesforce now sends email only from verified domains. Read More
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Calling Apex from Omniscripts with the Remote Action

          Calling Apex from Omniscripts with the Remote Action

          Call Apex classes from Omniscript using the Remote element, and use the Omniscript's JSON as input.

          Before you begin, create an Apex class in Salesforce to call from Omniscript. Include the ID in the SOQL query. That field is required because the Apex class retains the queries and serializes data according to what’s actually executed.

          1. Add a Remote element 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.
          2. In the Remote Class field, enter the name of the Apex class that the action calls.
          3. In the Remote Method field, enter a method of the class that the action calls. For example—validateAddress.
          4. If required, enable the subordinate Integration Procedure that calls long-running actions to use Apex continuations.
          5. In the Pre- and Post-Transform Omnistudio Data Mapper Interface—optionally select a Data Mapper Transform interface to run before or after the Remote Action.
          6. Change the amount of time before the action times out using the Remote Timeout property. In the element, click Edit Properties as JSON, and in the remoteTimeout property, set a time in milliseconds.
            The default timeout is 30,000, or 30 seconds. The maximum is 120,000, or 120 seconds.
          7. Configure additional properties in the Remote Action.
          8. Select the response behavior of the action by selecting an Invoke Mode.
            • Default — Blocks the UI with a loading spinner.

            • Non-Blocking — Runs asynchronously, and the response is applied to the UI. Pre and Post Omnistudio Data Mapper transforms and large attachments aren’t supported. When Invoke Mode is set to non-blocking, elements using default values won’t receive the response because the element loads before the response returns. To map the response to an element, you must set Response JSON Node to VlocityNoRootNode and Response JSON Path to the name of the element.

            • Fire and Forget — Runs asynchronously with no callback to the UI. Pre and Post Data Mapper transforms and large attachments aren’t supported. A response will still appear in the debug console but won’t be applied to the Data JSON.

          9. When Invoke Mode is set to non-blocking, elements using default values will not receive the response because the element loads before the response returns. You must configure these properties to map the response to an element:
            • Response JSON Node: VlocityNoRootNode

            • Response JSON Path: The name of the Omniscript Element receiving the value.

          Troubleshooting Omniscript
          Troubleshooting Omniscript

          In the Troubleshooting Omniscript, the callOut1 Remote Action element calls an external system to check if the asset is still under warranty. This example references the Troubleshooting Omniscript and the OmniCallout and DataObjectService Apex classes.

          It implements the Remote OmniCallout class and the remote checkWarrantyStatus method. Since this is a sample Omniscript, the method contains a hard-coded response:

          image

          The callOut2 Remote Action calls the returnItemOrder method, which in turn calls the DataObjectService class that calls out to a Heroku instance to return an order number:

          image

          The following class structure can be used to call out to an external system:

          global with sharing class CustomClassName implements NS.VlocityOpenInterface
             {
          
              global CustomClassName() {}
          			
              global Boolean invokeMethod(String methodName, Map<String,Object> inputMap, Map<String,Object> outMap, Map<String,Object> options) {
          			
                        Boolean result = true;
          			
                try{
          			
                       if(methodName.equals('customMethodName')){
          			
                       // your implementation, use outMap to send response back to OmniScript                                                                  
          			
                      }
          			
                      } 
           
          	else if(methodName.equals('customMethodName2')){
          			
                      // your implementation, use outMap to send response back to OmniScript                   
          			
                   }                              
          			
                } catch(Exception e){
          			           
                   result = false;
          			        
                }
          			 
                       return result;
          			      
             }
          			
          }
          
           
          Loading
          Salesforce Help | Article