In this use case, the custom datasource is used to include a fixed fund KPI in Real Time Report (RTR). As a result, the fixed funds are aggregated on both category and brand levels. One visualization option is this report, in which a brand value is only available for one brand. However, this value is not summed up to the category level. For the calculation of category levels, the data that’s stored on Salesforce and Processing Services is used.
Prerequisites
Create a KPI definition for the fund amount. For this KPI definition, ensure that the object scope is Account and it has the writeback feature enabled.
This KPI definition only provides a name for the external KPI. The Apex class defines how to enter values in this KPI.
Note
Enter the name of the datasource table as Account Measure.
Add the KPI to the Reporting KPI set that’s used in the report.
Report Configuration
Create new KPI definitions for each use case, such as Fixed RDF Brand. Ensure that the object scope of these KPI definitions is Account.
Enter the name of the datasource table as Account Measure.
Define these KPI definitions in the report configuration
Create a custom metadata type, TPM_RTRRouting__mdt, which is linked to the KPI definition, sales organization, fund template, and KPI levels.
Field API Name
Type
Description
Fund_Template__c
Text
Determines the KPI to which the fixed funds are to be attributed. For example, All Transaction Row Records, in which the target fund has the RDF Brand Fund that belongs to the Fixed RDF KPI.
KPI_Definition__c
Text
Name of the Fixed Funds KPI (such as FXDR and FTDR) that determines the data which should be returned from the logic in the Apex class.
KPI_Level__c
Text
Fixed funds can be stored on different levels (currently, category and brand). This is needed to determine the method that should be run. (category and brand use different logic.)
Sales_Org__c
Text
Sales organization to which the record belongs.
On the cgcloud__Fund_Transaction_Row__c object, add a new field.
Field API Name
Type
Description
Formula
TPM_RTRAmount__c
Formula (Double)
Fixed Funds for Brands are calculated based on the value of the Amount field on the transaction record. Depending on the transaction type (withdraw or deposit), the sum of the aggregated amounts either increases (deposit) or decreases (withdraw). The formula field turns the amounts of records with transaction type = deposit to negative values. Instead of aggregating the amount field, you can aggregate the TPM_RTR_Amount__c field.
On the cgcloud__Fund_Transaction_Header__c object, add a new field.
Field API Name
Type
Description
TPM_Product__c
Lookup(Product)
Used to link products to the Multi-Fund Transaction object.
On the cgcloud__Fund_Template__c object, add a new field.
Field API Name
Type
Description
TPM_RTRRoutingFundType__c
Picklist
Used to filter fund template records. The picklist values of this field are fund template record names.
Ensure that you create new fund templates for each case, such as RDF Brand Fund. Maintain the newly created TPM_RTRRoutingFundType__c field on the fund template.
Note
Apex Classes
Custom data sources are related to two base Apex classes. Because all reports share these classes, you can use both classes only for code-routing, not to perform any actual logic, queries, or calculations.
In RTR, the integration user runs both Apex classes, not the user who opens the report. As a result, the integration user must have access permissions for the used Apex classes.
TPM_RTRReportingWrapper_AMS is a base class that contains the structures to load the input. This class contains the list of KPIs and filter criteria that you chose in the report—selected time frame or the list of customers and products. Depending on various use cases, the payload method can contain different attributes.
TPM_RTRSalesforceMonthlyMeasures_AMS is the second base class that’s used for code-routing and is required to retrieve the information by a Salesforce REST endpoint (/services/apexrest/RTRSalesforceMonthlyMeasures).