Use Case: Fund Amount

The Fund object stores the fund amount in Salesforce. To show a fund amount for a particular category or brand, fetch it from the Salesforce database by using custom data sources.

Prerequisites 

  1. 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 input values in this KPI.

    Note

  2. Enter the name of the datasource table as Account Measure.

  3. Add the KPI to the Reporting KPI set that’s used in the report.

Report Configuration 

Apart from defining RTRSalesforceMonthlyMeasures as an additional datasource in the report configuration, ensure that you add the newly created KPI to the list of measures.

1{
2"label": "Fund Amount",
3"name": "myFndAmount"
4},

Apex Classes 

The custom data sources are related to two base Apex classes. You can use both classes only for code-routing and not to perform any actual logic, queries, or calculations; this is because all reports share these classes.

In RTR, integration users run both the Apex classes, not the user who opens the report. As a result, integration users must have access permissions to the used Apex classes.

Note

  • TPM_RTRReportingWrapper_AMS (Base Class)

    TPM_RTRReportingWrapper_AMS is a base Apex class that receives the payload that’s constructed by filter selection in the report. The payload contains the KPIs that are defined in the report, the customer, dates, and other important attributes. It then deserializes the payload into an object that can be used in all other related classes.

  • TPM_RTRSalesforceMonthlyMeasures_AMS (Base Class)

    TPM_RTRSalesforceMonthlyMeasures_AMS is one of the base classes that’s used for code-routing and is required to retrieve the information by a Salesforce REST endpoint (/services/apexrest/RTRSalesforceMonthlyMeasures).

  • TPM_RTRFunds_AMS (The Logic Class)

    Use RTRSalesforceMonthlyMeasures as the datasource to execute the base classes by every report.