TPM_RTRSalesforceMonthlyMeasures_AMS (Base Class)
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).
These are the code details:
-
The payload is received, and is then turned into an object of our wrapper class. The payload contains the KPIs that are defined in the report configuration.
-
The integration user runs the base classes, not the user who opens the report. As a result, ensure that you query an account on the payload that the user selected to retrieve the actual user’s sales org.
-
Helper maps and lists are created.
-
The dates from the payload are converted to a workable format.
-
The Apex class contains use case-specific code. Here, you can query all custom metadata records that were defined earlier and that belong to the sales org of the user. Then you can check whether the payload contains any KPIs in the custom metadata records. If it does, verify the level on which those KPIs are available and then add them to a dedicated map (category KPIs or brand KPIs map).
-
You can check whether the two maps (brandKPIs and categoryKPIs) contain any values — if not, nothing happens. If they do, the actual class where all the logic happens is called and parameters such as the payload are passed.