Share via


Example: Make a report context-sensitive

 

Applies To: Dynamics 365 (online), Dynamics 365 (on-premises), Dynamics CRM 2016, Dynamics CRM Online

The following steps describe how to set up a context-sensitive report in Microsoft Dynamics 365.

For example, if a report displays all activities for a particular account and you want to show this report on the Microsoft Dynamics 365Account form, you must include Activities and Accounts in the Related Record Types categorization and specify Forms for related record types in the Display in field of the Report: New form.

Create and configure a context-sensitive report

  1. Create a report that contains fields from a Filtered<entity> database view and establish one or more SQL JOINs with other related filtered views as required.

  2. Use CRMAF_Filtered<entity> as an alias name in the report's SQL query statement. Here’s an example.

    SELECT CRMAF_FilteredActivityPointer.activitytypecodename as
    activitytypecodename,
    CRMAF_FilteredActivityPointer.regardingobjectidname as regardingobjectidname,
    CRMAF_FilteredActivityPointer.subject as subject,
    CRMAF_FilteredAccount.name
    FROM FilteredActivityPointer AS CRMAF_FilteredActivityPointer
    INNER JOIN FilteredAccount As CRMAF_FilteredAccount on
    CRMAF_FilteredAccount.accountid = 
    CRMAF_FilteredActivityPointer.regardingobjectid
    

    If you have a Fetch-based report, you can use the following FetchXML query instead of the SQL query.

    <fetch>
      <entity name="activitypointer" enableprefiltering="1" >
        <attribute name="activitytypecode" />
        <attribute name="regardingobjectid" />
        <attribute name="subject" alias="subject" />
        <link-entity name="account" from="accountid" to="regardingobjectid" link-type='inner' alias="accountLink">
          <attribute name="name" alias="name" />
        </link-entity>
    </entity>
    </fetch>
    
  3. When you upload the report to Microsoft Dynamics 365 through the Report: New form, select all entities in the Related Record Types categorization that filtered views are referred to in the report's SQL code.

  4. In the Display In field, select Forms for related record types or Lists for related record types. Selecting Lists for related record types lets you run a report from the entity list grid. Selecting Forms for related record types lets you run a report from the entity form.

See Also

Example reports
Copy reports between Microsoft Dynamics 365 (on-premises) deployments
Report & Analytics with Dynamics 365

© 2016 Microsoft. All rights reserved. Copyright