Using Registered Objects
Registered Objects enables Spark Framework to track exceptions and errors through system logs, run rollup summaries and execute custom triggers on all managed objects. All Fonteva Objects are registered by default, but you can register customized objects manually via the UI or by script.
Essentially, Registered Objects allow you to wrap a standard Salesforce Object or Custom Object and make it available in your Fonteva app.
Scenario: Event Pages
Event Pages is the Object used as an example for this documentation. You can apply the code snippets provided to any object by changing the values within the structures.
Before You Begin
Before you begin registering objects, you must have a Registered app and set up your sObject Trigger. Every Namespace should have its own Registered App. Your Objects, Rollups, and API Services can all be grouped together under your Registered App.
Registered Apps
You cannot create a Registered App through Spark Admin. It must be created by injecting the following code from the Developer's Console.
Registering an App
Framework.RegisteredApp ev = new Framework.RegisteredApp();
ev.namespace = PackageUtils.namespace;
ev.name = 'Assemble';
ev.description = 'Fonteva Events (EventApi)';
ev.owner = 'Fonteva';
ev.isManaged = true;
ev.isEnabled = true;
ev.installClass = PackageScripts.Install.class.getName();
Framework.Config.push(ev);
Enter values to the following fields:
- name - The name of the app.
- description - What your app does.
- owner - The organization that owns the app.
- isManaged - If this App is a managed package, enter "true". If not, enter "false"
- isEnabled - Enter "true" in order to enable the app
- installClass - The Apex class that runs when you install or update this package. Although not a required field, if you have a script that you would like to run when the package installs, Fonteva recommends injecting it into your Apex class.
Once your App is installed, you will see it listed in your Configuration Summary.
- Removing your Registered App also removes all the associated Objects, Rollups, Routing Rules, and API Services.
- See https://fonteva.atlassian.net/wiki/spaces/userguide/pages/854240666 for more information on Registered Apps.
Order of Execution
When a Registered Object is correctly configured, it will allow a specific series of actions.
The sObject Trigger fires the Dispatcher. The Dispatcher pulls together your Registered Objects and all associated Routing Rules and executes the Domain Classes in the specified order.
The following pages will outline how to correctly configure a new Registered Object
Setting Up Your sObject Trigger
A sObject Trigger ensures the proper method is called in Fonteva's Framework. This file validates that you have a Registered Object and executes the Domain Class within that object. See Apex Class for more information on Domain Classes.
.trigger File Structure
trigger EventPageTrigger on Event_Page__c (before insert, before update, before delete, after insert, after update, after delete) {
Framework.Dispatcher.dispatchTrigger();
}