RTRReportResult

The RTRReportResult Apex class provides methods to access and process RTR reports.

Namespace

The supported modifiers are global, virtual, and with sharing.

1cgcloud

Supported Methods

Table 1. RTRReportResult Supported Methods
Method signature Description Version
static RTRReportResult execute(String name, String salesOrg, Map<String, Object> filters) Executes an RTR report and retrieves all the report data.
  • name: String. The internal name of the RTR report configuration to execute.
  • salesOrg: String. The sales org name to execute the report.
  • filters: Map<String, Object>. The report filters as defined in the RTR report metadata. For a list of possible filter types, see Report Execution Filter Types and Limits.
60.0
static void setMock(List<Object> results) Sets up mock results for unit test execution.

results: List<Object>. A list of object instances of type:

  • RTRReportResult
  • RTRReportResult.MockException

When running unit tests, the system returns the mock value of the results in the order in which they were specified. For example, for the third execute call, the third item on the list is returned.

If the mock result is an instance of RTRReportResult.MockException, the method throws CGCloudException.

60.0
ReportComponent getComponent(String name) Retrieves an instance of the reporting UI component.

name: String. The reporting component name as defined in theuimapping report metadata.

To access the information inside the report, cast the result of this method to the correct type. For example, if the component is Flatlist, cast the return to RTRReportResult.Flatlist.

This method throws an exception if the component doesn’t exist in the report, or it’s not from a valid type.

60.0
String getSalesOrg() Returns the sales org used for the RTR report execution. 60.0
String getReportName() Returns the report name used for the RTR report execution. 60.0
Map<String, Object> getFilters() Returns the filters used for the RTR report execution. 60.0

Example Implementation

Here’s an example implementation of the execute method.
1cgcloud.RTRReportResult reportResult = cgcloud.RTRReportResult.execute(
2    'Promotion Report',  // Report Name
3    '0001',  // Sales Org
4    new Map<String, Object> { // Report filters
5        'periodmonth' => new Map<String, Object> {
6            'start' => 0,
7            'total' => 12,
8            'year' => 2022
9        },
10        'accountsfids' => new List<String> {'001SL0000004dfgYAA'},
11        'productsfids' => new List<String> {'01tSL00000018oNYAQ'},
12        'promo_templatesfid' => new List<String> {'a2USL0000000js12AA', 'a2USL0000000jrz2AA'},
13        'promo_phase' => new List<String> {
14            'Planning',
15            'Modeling',
16            'Committed',
17            'ForApproval'
18        },
19        'productlevel'=> 'product'
20    }
21);
Here’s an example implementation of how to use the setMock method to unit test multiple execute calls.
1@IsTest
2  public static void myTestMethod() {
3    // Setup
4    
5    // Setup your required data for the test
6    
7    // Create a mock RTRReportResult
8    cgcloud.RTRReportResult.MockRTRReportResult mockReportResult1 = ...
9    cgcloud.RTRReportResult.MockRTRReportResult mockReportResult2 = ...
10    cgcloud.RTRReportResult.MockException mockException = ...
11    
12    // Set the mock in RTRReportResult.execute so the call to this method
13    // returns our mock response
14    cgcloud.RTRReportResult.setMock(
15      new List<Object>{ mockReportResult1, mockReportResult2, mockException }
16    );
17    
18    // Test
19    
20    // Run your code to be tested. RTRReportResult.execute call will
21    // return each mock result (RTRReporResult or throw exception)
22    // for each "execute" method called.
23    // - First execute call will return first mock in list
24    // - Second execute call will return second mock in list
25    // - Third execute call will return third mock in list (in this case, it'll throw an exception)
26    
27    // Assert
28    
29    // Assert your code is working as expected.
30  }