Enabling Source Value Aggreation
To support reporting purposes, for example, you can set up JustOn Billing & Invoice Management to aggregate invoice and invoice line item fields on related object records. Generally, there are two ways to do so:
Value aggregation using prefixed aggregation fields upon invoice finalization
Value aggregation using a flow for any defined fields
Value Aggregation Using Prefixed Fields
JustOn Billing & Invoice Management allows for aggregating the values of specific invoice line item fields on subscriptions or items.
To this end, you configure aggregation fields on the item or subscription, where the API name is the same as the invoice line item field, prefixed with CALC_. To aggregate, for example, the quantity of a particular line item, you map the field Quantity__c (the API name) of the invoice line item to the field CALC_Quantity__c (again, the API name) of the item.
The aggregation is executed during the finalization of the invoice.
To add aggregation fields to the item or subscription:
Navigate to the fields list of the Item or Subscription object.
Click New to create the aggregation fields as required.
You can aggregate the values of all fields with numeric values, like quantity, price, discount amount, etc.
Note that the aggregation fields must have the same API name as the source fields, prefixed with CALC_.
For help about creating fields, see Managing Object Fields.
Flow-Based Value Aggregation
Your business may require to show certain information of related invoices on an account or the source object based on which invoices are generated, like opportunities or contracts. To this end, you can set up a flow that calculates an aggregation on invoices and writes the result to fields on a source object.
Think of the following example: You (repeatedly) generate invoices based on opportunities, that is, you produce multiple invoices from one opportunity. Now you want to show the number of generated invoices and the sum of the invoice totals on the corresponding opportunity record.
Aggregating invoice values on a related parent record
If configured accordingly, the flow counts the produced invoices as well as sums up the grand total of all produced invoices, and then writes the result to the corresponding fields of the opportunity.
Info
The implemented aggregation uses SOQL aggregate queries internally where the result is grouped by the field that points to the parent.
Setting up the flow-based value aggregation involves two tasks:
Creating aggregation fields on the source object
Creating Aggregation Fields
On the related source object, you create the target fields for the values to be aggregated. These fields must comply with the following naming pattern: <PREFIX>_<FUNCTION>_<FIELDNAME>.
Field Name Part | Description |
|---|---|
PREFIX | Specifies the group of aggregation target fields on the source object (by default |
FUNCTION | Specifies the intended aggregate function: |
FIELDNAME | Specifies the API name of the field that is to be aggregated. |
To add the aggregation fields on the source object:
Navigate to the fields list of the source object.
Click New to create the aggregation fields as required.
Make sure to comply with the naming pattern as described above.For help about creating fields, see Managing Object Fields.
Creating Aggregation Flow
Calculating the aggregation and updating the source record requires a flow that calls the appropriate Apex class provided by JustOn.
Note
Depending on your use cases, the flow setup and the objects to involve will vary.
Click ⚙️ to enter Setup, then navigate to Process Automation > Flows.
Click New Flow.
Select
Record-Triggered Flowand click Create.Configure the Start element.
Option | Description |
|---|---|
Object | The object whose record modifications are to update a source record, must be |
Trigger | The type of record change that triggers the flow |
Conditions | The use case-specific trigger conditions, one or more filter criteria for evaluating certain field values |
Optimize for |
|
Click
and add the following Action element.
Option | Description |
|---|---|
Action | The Apex class to call, must be |
Input Values | Invocable variables for the Apex class |
Specify a label and an API name as required.
Click Save.
Specify a label and an API name as required.
Click Activate.
→ When the defined conditions are met, JustOn triggers the flow. It aggregates the configured invoice fields and writes the results to the target fields on the source object record.
For help about creating flows, see Flows in the Salesforce Help.