Newer Version Available
TPM_RTRFunds_AMS (The Logic Class)
Use RTRSalesforceMonthlyMeasures as the datasource to execute the base classes by every
report.
| Available in: Lightning Experience in Enterprise, Professional, and Unlimited Editions that have Consumer Goods Cloud enabled |
This function performs these steps:
- Defines a list of output record items.
- Retrieves the fund amounts from Salesforce data by using SOQL, depending on the use case. In this example, only funds at the category level are shown. You can use the category filter as the selection criterion. The funds are also limited to the account and time frame that's selected in the filter.
- For every result record, the function creates an output record and adds it to the list of results.
1global with sharing class TPM_RTRFunds_AMS{
2global static List<TPM_RTRReportingWrapper_AMS.OutputRecord>
3doPost(Date inputDateBegin , Date inputDateEnd,
4TPM_RTRReportingWrapper_AMS.InputPayload payload) {
5List<TPM_RTRReportingWrapper_AMS.OutputRecord> output =
6new List<TPM_RTRReportingWrapper_AMS.OutputRecord> ();
7String pdim ;
8String kdim ;
9String tdim ;
10Double v ;
11AggregateResult[] groupedResults = [SELECT cgcloud__Anchor_Product__c,
12sum (cgcloud__Deposits_Approved__c ) sumValue
13from cgcloud__Fund__c
14WHERE cgcloud__Anchor_Product__c IN :payload.productsfids
15AND cgcloud__Anchor_Account__c IN :payload.accountsfids
16AND ((cgcloud__Valid_From__c <= :inputDateEnd
17AND cgcloud__Valid_From__c >= :inputDateBegin)
18OR (cgcloud__Valid_Thru__c <= :inputDateEnd
19AND cgcloud__Valid_Thru__c >= :inputDateBegin))
20group by cgcloud__Anchor_Product__c
21];
22for(Integer i=0; i < groupedResults.size(); i++) {
23v =(Double) groupedResults[i].get('sumValue');
24pdim =(String) groupedResults[i].get('cgcloud__Anchor_Product__c');
25kdim = 'myFndAmount';
26tdim = 'Total';
27output.add(new TPM_RTRReportingWrapper_AMS.OutputRecord(pdim ,kdim, tdim, v));
28}
29return output;
30}
31}