web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Help with Pre-Filtered SQL Report for On-Premise

(0) ShareShare
ReportReport
Posted on by

I cannot for the life of me get a Pre-Filtered SQL Report to work with on our On-Premise CRM server running 8.2. 

I'm trying to create a very simple SQL report that will only run on the currently opened account.  Even though what I'm currently doing is very simple, I'm using SQL because the end result that I'd like to achieve will require complex queries.

Issue: After I upload my report to CRM, and go to a specific Account; I only see the new report under the Run on All Records rather than Run on Current Record.

Steps Taken:

  1. Created new blank report in Visual Studio in my SSRS project.  I have other SQL reports, but none are Pre-filtered.
  2. Created a new DataSource based on my Shared DataSource in the project.
  3. Added a hidden parameter called CRM_FilteredAccount with a default value of select  \[account0\].*  from  FilteredAccount as "account0".
  4. Added a dataset referencing the datasource with a SQL query of
    1. declare @sql as nVarchar(max)

      set @sql = '
      SELECT top 10 CAST(accountid as nvarchar(100)) as AccountID, name
      FROM (' + @CRM_FilteredAccount + ') as fa'

      exec(@sql)
  5. On the dataset, linked the query parameter "@CRM_FilteredAccount" to the report parameter.
  6. Clicked OK, entered select [account0].*  from  FilteredAccount as "account0" when prompted for the parameter value to get the fields.
  7. Added a table to the report, dragging AccountID and name to the fields and saved the report.
  8. In CRM, went to Customization, Customize the System.
  9. In the Reports section, added a new Report.  Changed from Report Wizard to Existing File and browsed to my saved RDL file.
  10. Under Related Record Types, selected Account.
  11. Under Display in, I removed Reports area and added the List and Form items
  12. Clicked Save and Close
  13. Publish all customizations
  14. Browse to a specific account and the new report is only under Run on All Records

I based what I did above on reading multiple articles and tearing apart the Account Overview report, which kind of behaves the way I want my report to work.

Does anybody have any idea why the report won't display under Run on Current Record? 

*This post is locked for comments

I have the same question (0)
  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: Help with Pre-Filtered SQL Report for On-Premise

    Hello,

    If initial report doesn't contain prefiltering - update with newer version of report will not change this. Delete initial report in CRM and just create new based on your RDL.

    Also - don't use "Shared Datasource" in your report - use "Datasource Embedded to Report".

  • Larry Pope Profile Picture
    on at
    RE: Help with Pre-Filtered SQL Report for On-Premise

    Andrew,

    Thank you for the help.  Changing to an embedded data source was the trick.  Everytime I make a change to the report, I do delete and re-add it because I saw that for Pre-Filtering if you didn't do it right the first time, it wouldn't always add it to the run on Current Record.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Community Member Profile Picture

Community Member 2

#1
UllrSki Profile Picture

UllrSki 2

#3
SC-08081331-0 Profile Picture

SC-08081331-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans