Routing Rules control the behavior of how the system routes logic for processing when objects are inserted, updated, and deleted from the database. Routing Rule support must be provided when integrating a new Registered Object into the Spark service layer. Routing Rules must be created from a different Namespace from the Registered Object.

For more technical information on Routing Rules, please read Creating Routing Rules in Fonteva's Developer Documentation.

Creating a Routing Rule for an Object:

Routing Rules control the behavior of how the system routes logic for processing when objects are inserted, updated, and deleted from the database. It is used to extend an object's trigger so you can build on existing functionality. For the instructions below, we are using an example where we want to extend triggers for Fonteva’s Receipt Object. This is only necessary for objects in managed packages because the code in managed packages is hidden and cannot be edited.  If the object is part of an unmanaged package or is custom in your environment, you can extend the functionality directly in your code. A Domain Class (Apex Class) is needed for the object you want to create a Routing Rule for. We've provided the necessary code below that will be used to create the Apex Class for the object you want to create a Routing Rule for, but you will need to provide your own custom code you want to include to extend the trigger.

Step 1 - Create an Apex Class for the Object:

Domain Class Code:

Apex Class Code
global class PLURAL_OBJECT_NAME extends Framework.Domain {

    public PLURAL_OBJECT_NAME(List<OBJECT_API_NAME> sObjectList) {

    global class Constructor implements Framework.Domain.DomainConstructor {
        public Framework.Domain construct(List<SObject> sObjectList) {
            return new PLURAL_OBJECT_NAME(sObjectList);
  1. Click the Gear icon and select Developer Console.

  2. From the Developer Console, click File to expand the file menu, then click New and select Apex Class to open the New Apex class window.

  3. In New Apex class window, type a name for the new Apex Class. This must be the plural name of the object you are going to create a Routing Rule for. Example: Object name = Receipt so the plural name used for the Apex Class = Receipts.

  4. Click OK in the New Apex class window.

  5. The Developer Console now displays the newly created "Apex Class" tab with default code lines displayed. 

  6. Select and delete the default code listed and copy and paste the Domain Class Code into the Developer Console window. Disregard any problem listed regarding the OBJECT-API_NAME as we will change the code in the following steps.

  7. In the code lines, replace all instances of the text PLURAL_OBJECT_NAME with the Plural Name of the Object your are registering. Example: Object name = Receipt so the Plural Name = Receipts. 

  8. Replace the OBJECT_API_NAME text with the API name of the Object you are registering. Example: OrderAPI__Receipts__c . Make sure it is entered in between the <> . Always remember the API name of a packaged object includes the namespace. Example: Namespace = OrderAPI

  9. Type any custom code to extend the trigger.

  10. After entering in your custom code, click File and click Save.

Step 2 - Create a Routing Rule in Spark:

Once a Domain Class (Apex Class) has been created and the desired custom code is added, the second step is to create the Routing Rule in Spark. 

  1. Navigate to the Spark Admin tab and click Routing Rules. This opens the Routing Rules page.

  2. Click the + New Routing Rules button. This opens the New Routing Rule window.

  3. In the SObject Name field, type the SObject name. This will be the namespace followed by the object name. Example: If the Namespace = OrderAPI__ and Object Name = Receipt__c together the SObject name would be OrderAPI­­­­­­__Receipt__c.

  4. In the Namespace field, type the namespace of the app that manages the rule. Example: OrderAPI

  5. In the Apex Class field, type the name of the Domain (Apex Class) created in Step 1. Type the name of the Apex Class containing the logic for the SObject requiring the rule.

  6. In the Execution Order field, type a number to be the order in which the trigger will fire. If you have multiple triggers for a single object you can change the execution order to make sure they fire in the desired order. Leave as zero if no order exists. It is strongly encouraged to include execution orders so the order of execution can be guaranteed.

  7. Check Is Enabled. If Is Enabled isn't checked, the object won’t show in Rollup Summaries, and Triggers won't fire.

  8. Click Save.

How to Edit or Delete Routing Rules:

  1. From the Routing Rules page, navigate to the row of the desired routing rule.

  2. In the Action column for the desired object, click the Arrow button.

  3. Click Edit to review or modify the routing rule's settings. You can also click Delete to delete the object.

  4. From the Edit Routing Rule window, make the desired changes.

  5. Click Save.