Object Tree
Introduction
With the Object Tree capability it’s possible to load into a Hierarchical Map any complex structure of records stored in Salesforce. This is required as Salesforce out of the box only grants two ways to load data structures:
- SOQL: Which only allow two levels of nested objects.
- Composite Object API: Which only allow up to 5 levels and it requires to consume the Salesforce API from Salesforce itself which has different drawbacks as: bad design, api limits consumption and performance. Additionally, the flexibility of this service is limited.
With the Wattyo Object Tree you are able to define the expected hierarchy, both leveraring existing object relationships or defining runtime custom ones (TO BE IMPLEMENTED)
It also allows different handy options to customize the resulting hierarchy, as removing junctions / parent objects from the hierarchy, or override relationship names.
The Object Tree is a feature that is used almost in all Wattyo Modules / Functionalities as it speed ups and simplifies the development of complex functionalities. It’s a key feature in the Wattyo Framework.
Example
Let’s imagine we have the following hierarchy:
- Account
- Contacts
- Opportunities
- Opportunity Products
- Product
- Opportunity Products
- Opportunities
- Cases
- Case Comments
- Case Attachments
- Assets
- Asset Attachments
- Asset History
- Asset History Events
- Contacts
In this case we could define the Object Tree structure to automatically load all this hierarchy in a single call to the Object Tree Engine and retrieve only the fields we need for each of them.
Advantages
Some of the advantages of using the Object Tree Engine are:
- Performance: It’s a very performant way to load complex hierarchies of records as it optimize the number of queries and the amount of data retrieved.
- Flexibility: It allows to define the hierarchy in a very flexible way, leveraging existing relationships or defining runtime ones.
- Customization: It allows to customize the resulting hierarchy, removing junctions / parent objects from the hierarchy, or override relationship names.
- Cache: It caches the Object Tree definition once is parsed, so it doesn’t need to be parsed again for the same Object Tree which drastically improves the performance.
- Reduce Custom Code: It reduces the amount of custom code required to load complex hierarchies of records which is a very common scenario along any functionality.