---
schema_version: "1"
id: 3d9f9f753b3d73fb04d7ed66c3871c2ec018c65d43817120511377fde6ad57af
title: RTRReportResult
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/retail_api/RTRReportResult_class.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.retail_api.meta/retail_api/RTRReportResult_class.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 0fc2aa97965192a9ccb3f1cb1c68ce547146c035bce63ada7062abbbeaefed72
description: The RTRReportResult Apex class provides methods to access and process RTR reports.
---
# RTRReportResult

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

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

## Namespace

cgcloud

## Supported Methods

<table class="featureTable sort_table" summary="">
          <caption><span class="tablecap">Table 1. RTRReportResult Supported Methods</span></caption>



          <thead class="thead sorted" align="left">
            <tr>
              <th class="featureTableHeader  " id="d36051e83">Method signature</th>

              <th class="featureTableHeader  " id="d36051e86">Description</th>

              <th class="featureTableHeader  " id="d36051e89">Version</th>

            </tr>

          </thead>

          <tbody class="tbody">
            <tr>
              <td class="entry" headers="d36051e83" data-title="Method signature"><samp class="codeph nolang">static RTRReportResult execute(String name, String
                  salesOrg, Map&lt;String, Object&gt; filters)</samp></td>

              <td class="entry" headers="d36051e86" data-title="Description">Executes an RTR report and retrieves all the report data. <ul class="ul bulletList">
                  <li class="li">
                    <span class="keyword parmname">name</span>: String. The internal name of the RTR report configuration to
                    execute.
                  </li>

                  <li class="li">
                    <span class="keyword parmname">salesOrg</span>: String. The sales org name to execute the report.
                  </li>

                  <li class="li">
                    <span class="keyword parmname">filters</span>: Map&lt;String, Object&gt;. The report filters as defined in
                    the RTR report metadata. For a list of possible filter types, see <a class="xref" href="https://developer.salesforce.com/docs/atlas.en-us.retail_api.meta/retail_api/report_execution_filters.htm" title="Here are the different types of filters you can specify to execute a report.">Report Execution Filter Types and Limits</a>.
                  </li>

                </ul>
              </td>

              <td class="entry" headers="d36051e89" data-title="Version">60.0</td>

            </tr>

            <tr>
              <td class="entry" headers="d36051e83" data-title="Method signature"><samp class="codeph nolang">static void setMock(List&lt;Object&gt;
                  results)</samp></td>

              <td class="entry" headers="d36051e86" data-title="Description">Sets up mock results for unit test execution.<p class="p"><span class="keyword parmname">results</span>:
                  List&lt;Object&gt;. A list of object instances of type:</p>
                <ul class="ul bulletList">
                  <li class="li"><samp class="codeph nolang">RTRReportResult</samp></li>

                  <li class="li"><samp class="codeph nolang">RTRReportResult.MockException</samp></li>

                </ul>
                <p class="p">When running unit tests, the system returns the mock value of the results in the
                  order in which they were specified. For example,&nbsp;for the third execute call, the third item
                  on the list is returned.</p>

                <p class="p">If the mock result is an instance of <samp class="codeph nolang">RTRReportResult.MockException</samp>, the method throws <samp class="codeph nolang">CGCloudException</samp>.</p>
              </td>

              <td class="entry" headers="d36051e89" data-title="Version">60.0</td>

            </tr>

            <tr>
              <td class="entry" headers="d36051e83" data-title="Method signature"><samp class="codeph nolang">ReportComponent getComponent(String name)</samp></td>

              <td class="entry" headers="d36051e86" data-title="Description">Retrieves an instance of the reporting UI component. <p class="p"><span class="keyword parmname">name</span>:
                  String. The reporting component name as defined in the<span class="ph filepath">uimapping</span> report
                  metadata.</p>
                <p class="p">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 <samp class="codeph nolang">RTRReportResult.Flatlist</samp>.</p>
                <p class="p">This method throws an
                  exception if the component doesn’t exist in the report, or it’s not from a valid
                  type.</p>
              </td>

              <td class="entry" headers="d36051e89" data-title="Version">60.0</td>

            </tr>

            <tr>
              <td class="entry" headers="d36051e83" data-title="Method signature"><samp class="codeph nolang">String getSalesOrg()</samp></td>

              <td class="entry" headers="d36051e86" data-title="Description">Returns the sales org used for the RTR report execution.</td>

              <td class="entry" headers="d36051e89" data-title="Version">60.0</td>

            </tr>

            <tr>
              <td class="entry" headers="d36051e83" data-title="Method signature"><samp class="codeph nolang">String getReportName()</samp></td>

              <td class="entry" headers="d36051e86" data-title="Description">Returns the report name used for the RTR report execution.</td>

              <td class="entry" headers="d36051e89" data-title="Version">60.0</td>

            </tr>

            <tr>
              <td class="entry" headers="d36051e83" data-title="Method signature"><samp class="codeph nolang">Map&lt;String, Object&gt; getFilters()</samp></td>

              <td class="entry" headers="d36051e86" data-title="Description">Returns the filters used for the RTR report execution.</td>

              <td class="entry" headers="d36051e89" data-title="Version">60.0</td>

            </tr>

          </tbody>

        </table>

## Example Implementation

Here’s an example implementation of the execute method.

cgcloud.RTRReportResult reportResult = cgcloud.RTRReportResult.execute(
    'Promotion Report',  // Report Name
    '0001',  // Sales Org
    new Map<String, Object> { // Report filters
        'periodmonth' => new Map<String, Object> {
            'start' => 0,
            'total' => 12,
            'year' => 2022
        },
        'accountsfids' => new List<String> {'001SL0000004dfgYAA'},
        'productsfids' => new List<String> {'01tSL00000018oNYAQ'},
        'promo\_templatesfid' => new List<String> {'a2USL0000000js12AA', 'a2USL0000000jrz2AA'},
        'promo\_phase' => new List<String> {
            'Planning',
            'Modeling',
            'Committed',
            'ForApproval'
        },
        'productlevel'=> 'product'
    }
);

Here’s an example implementation of how to use the setMock method to unit test multiple execute calls.

@IsTest
  public static void myTestMethod() {
    // Setup
    
    // Setup your required data for the test
    
    // Create a mock RTRReportResult
    cgcloud.RTRReportResult.MockRTRReportResult mockReportResult1 = ...
    cgcloud.RTRReportResult.MockRTRReportResult mockReportResult2 = ...
    cgcloud.RTRReportResult.MockException mockException = ...
    
    // Set the mock in RTRReportResult.execute so the call to this method
    // returns our mock response
    cgcloud.RTRReportResult.setMock(
      new List<Object>{ mockReportResult1, mockReportResult2, mockException }
    );
    
    // Test
    
    // Run your code to be tested. RTRReportResult.execute call will
    // return each mock result (RTRReporResult or throw exception)
    // for each "execute" method called.
    // - First execute call will return first mock in list
    // - Second execute call will return second mock in list
    // - Third execute call will return third mock in list (in this case, it'll throw an exception)
    
    // Assert
    
    // Assert your code is working as expected.
  }