Skip to main content

Notifications

Dynamics 365 general forum
Unanswered

Dynamics SSRS Report not selecting current Account in PreFiltered Report

Posted on by Microsoft Employee
Hello Community

I have a report which I have built to use the current selected account. The issue is that the report still selects all records instead of the current selected one. I have created a Parameter named "CRM_FilteredAccount" and set the default value to:

Select * from FilteredAccount

Then I create the query like this:

declare @sql as nVarchar(max)
set @sql = '
SELECT 
    CRMAF_org.bsv_targetgroupattribute1, 
    pos.bsv_address_multiline, 
    pos.bsv_memberlist_memberlistcode, 
    pos.owneridname, 
    mbl_bsv_memberlist.bsv_memberlistcode, 
    pos.bsv_count_german, 
    pos.bsv_count_french,
    pos.bsv_count_italian,
    pos.bsv_count_rr,
    pos.bsv_count_english
FROM Filteredbsv_memberlist as mbl_bsv_memberlist LEFT JOIN 
Filteredbsv_memberrelation as pos ON pos.bsv_memberlist = mbl_bsv_memberlist.bsv_memberlistid LEFT JOIN 
('   @CRM_FilteredAccount   ') as CRMAF_org ON CRMAF_org.accountid = pos.bsv_organization'

exec(@sql)


To enable the PreFiltering I've set the CRMAV_ Prefix for the FilteredAccount alias and added the parameter to the query like shown above.

So the XML of the Parameter looks like this:

    
      String
      true
      
        
          Select * from FilteredAccount
        
      
      true
      CRM_FilteredAccount
      true
    
  

And the dataset:

      
        BSV
        
          
            =Parameters!CRM_FilteredAccount.Value
          
        
        declare @sql as nVarchar(max)
set @sql = '
SELECT 
    CRMAF_org.bsv_targetgroupattribute1, 
    pos.bsv_address_multiline, 
    pos.bsv_memberlist_memberlistcode, 
    pos.owneridname, 
    mbl_bsv_memberlist.bsv_memberlistcode, 
    pos.bsv_count_german, 
    pos.bsv_count_french,
    pos.bsv_count_italian,
    pos.bsv_count_rr,
    pos.bsv_count_english
FROM Filteredbsv_memberlist as mbl_bsv_memberlist LEFT JOIN 
Filteredbsv_memberrelation as pos ON pos.bsv_memberlist = mbl_bsv_memberlist.bsv_memberlistid LEFT JOIN 
('   @CRM_FilteredAccount   ') as CRMAF_org ON CRMAF_org.accountid = pos.bsv_organization'

exec(@sql)

What I dont know is if the CRMAF_ prefix will only be evaluated by dynamics if it is placed right after the FROM in the query. Maybe this construct does not work if the prefilter prefix is part of a join?

Categories:

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

Dynamics 365 Community Update – Sep 16th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,522 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,441 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans