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).

The system sends the selected filter criteria and the list of KPIs as input payload to the REST endpoint. The APEX REST method then returns the fund amounts as output records to show in the report.

The fund values are returned by a function that's executed when a POST request is sent.

These steps are run within the Apex function:
  1. The payload with filter values is converted into a format that can be used in the Apex code.
  2. The time range (start and end date) is built by the selected month information.
  3. The function that contains the logic for this use case is invoked.

Sample Code


@RestResource(urlMapping='/RTRSalesforceMonthlyMeasures/*')
global with sharing class TPM_RTRSalesforceMonthlyMeasures
{
@httpPost
global static List<TPM_RTRReportingWrapper_AMS.OutputRecord> doPost() {
String requestBody = RestContext.request.requestbody.tostring();
TPM_RTRReportingWrapper_AMS.InputPayload payload = (TPM_RTRReportingWrapper_AMS.InputPayload)
JSON.deserialize (requestBody , TPM_RTRReportingWrapper_AMS.InputPayload.class);
Date inputDateBegin = Date.newInstance(payload.periodmonth.year,payload.periodmonth.start,1);
Date inputDateEnd = inputDateBegin.addMonths( payload.periodmonth.total );
return TPM_RTRFunds_AMS.doPost( inputDateBegin , inputDateEnd, payload);
}
}