The Axsy Mobile App's Flow Engine supports the running of Apex Actions from the Axsy Mobile App with the execution of a Flow, providing the device is online. See this article on Checking Connectivity in Flow: Flow Check Connectivity Element.


As Apex can only be run on Salesforce, some additional configuration is required to run the Apex action from the Axsy Mobile app.


Expose Apex Class as a REST Web Service


In order to expose an Apex class, the class must:

  1. Be annotated with @RestResource(urlMapping='/<youruniqueendpoint>/*')
  2. Have a method annotated with the REST method @HttpPost


NOTE: The class exposed as a REST resource can be a new Apex class that will handle the REST request.


For more information on how to expose an Apex class as a REST Web Service, please see this Salesforce documentation: Exposing Apex Classes as REST Web Services


Configure the POST Method

The POST method configured should always:

  1. Convert a RestRequest input to a request argument class using JSON.deserialize. The request argument class is the input into your InvocableMethod.
  2. Call the InvocableMethod.
  3. Convert the output from your method using JSON.serialize and set the responseBody.
  4. Set the statusCode to indicate a success (200).
  5. Handle errors, and set the statusCode to indicate error (400).


See Figure 1 for an example POST method. This implementation should always follow this pattern to ensure the same functionality on web and mobile.


Figure 1 - Example POST Method


Configure Additional Inputs

An additional variable is required to be added the request class configured for your Apex class. This is the REST endpoint you specified for the Apex class, and should be named axsyEndpoint.


Figure 2 - Additional Invocable Variable Required



When configuring your Flow, you must make sure to specify the endpoint.


Adding Apex Action Element in Flow

When adding an Apex Action to a Flow, you can configure the element as you normally would. 


To ensure that the element works as expected on the Axsy Mobile app, you must ensure that the REST endpoint has been provided.


Figure 3 - Action Element in Flow Designer


Figure 4 - Configure Axsy Mobile Endpoint Input Value



Best Practice

As Apex Actions can only be run online, it is best practice to include the Connectivity Check Element followed by a Decision Element before running the Action. This will ensure that the expected logic is run, and to ensure that the Apex Action runs without errors. See this article for more information: Flow Check Connectivity Element.


Additionally, if the Apex Action performs some data manipulation, such as creating related records, it is important to use the 'Sync Records' element to ensure that these changes have been synced to the Axsy Mobile app. See this article for more information: Flow Sync Element.


Figure 5 - Apex Action with Online Check and Sync Records