---
schema_version: "1"
id: 1475614b28fc45ae15f635fdab3996b36d71142698365c0d0b3aedbf4fd2e071
title: TPM_RTRFunds_AMS (The Logic Class)
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/cgcloud_rtr_dev_guide/tpm_rtr_class_rtrfunds_ams.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.cgcloud_rtr_dev_guide.meta/cgcloud_rtr_dev_guide/tpm_rtr_class_rtrfunds_ams.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 6ea23e8e91cb257cf2d36812fdf9d0de7e015d3cbd7530927628f824bea80b1f
description: Use RTRSalesforceMonthlyMeasures as the datasource to execute the base classes by every report.
---
# TPM\_RTRFunds\_AMS (The Logic Class)

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

This function performs these steps:

1. Defines a list of output record items.
2. 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.
3. For every result record, the function creates an output record and adds it to the list of results.

**Sample Code**

global with sharing class TPM\_RTRFunds\_AMS{
global static List<TPM\_RTRReportingWrapper\_AMS.OutputRecord>
doPost(Date inputDateBegin , Date inputDateEnd,
TPM\_RTRReportingWrapper\_AMS.InputPayload payload) {
List<TPM\_RTRReportingWrapper\_AMS.OutputRecord> output =
new List<TPM\_RTRReportingWrapper\_AMS.OutputRecord> ();
String pdim ;
String kdim ;
String tdim ;
Double v ;
AggregateResult\[\] groupedResults = \[SELECT cgcloud\_\_Anchor\_Product\_\_c,
sum (cgcloud\_\_Deposits\_Approved\_\_c ) sumValue
from cgcloud\_\_Fund\_\_c
WHERE cgcloud\_\_Anchor\_Product\_\_c IN :payload.productsfids
AND cgcloud\_\_Anchor\_Account\_\_c IN :payload.accountsfids
AND ((cgcloud\_\_Valid\_From\_\_c <= :inputDateEnd
AND cgcloud\_\_Valid\_From\_\_c >= :inputDateBegin)
OR (cgcloud\_\_Valid\_Thru\_\_c <= :inputDateEnd
AND cgcloud\_\_Valid\_Thru\_\_c >= :inputDateBegin))
group by cgcloud\_\_Anchor\_Product\_\_c
\];
for(Integer i=0; i < groupedResults.size(); i++) {
v =(Double) groupedResults\[i\].get('sumValue');
pdim =(String) groupedResults\[i\].get('cgcloud\_\_Anchor\_Product\_\_c');
kdim = 'myFndAmount';
tdim = 'Total';
output.add(new TPM\_RTRReportingWrapper\_AMS.OutputRecord(pdim ,kdim, tdim, v));
}
return output;
}
}