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)

Prefiltering not working - Sql query

(0) ShareShare
ReportReport
Posted on by 510

I have seen many articles that show how to use PreFiltering in SSRS with Sql query. They said to use CRMAF_[FilteredView] but didn't work for me and ever brings me the first Quote, not the current Quote.

I removed the sql query with CRMAF_ because it was not working well.

I have 3 DataSets

The main DataSet is this one:

SELECT
[produto].productid AS [productid]
,[produto].productnumber AS [productnumber]
,[produto].name AS [productname]
,[produto].description AS [description]
,[produto].smart_especificacaotecnica AS [productspecification]
,[produto].smart_buidname AS [BU]
,[produto].smart_especialidadesname AS [especialidade]
,[produto].ptr_representadaidname AS [representada]
,[produto].smart_gruponame AS [grupo]
,[produto].smart_subgruponame AS [subgrupo]
,[produto].smart_registroanvisa AS [registroanvisa]
,[produto].smart_lp_fabricantename AS [fabricante]
,[produto].ptr_ncm AS [ncm]

,[linha].priceperunit as [price]
,[linha].smart_valor_ipi as [ipi]
,[linha].smart_percentualipi as [percentualipi]
,[linha].smart_valor_unitario_ipi as [ipiunitario]
,[linha].tax as [tax]

,cast([linha].quantity as decimal) as [quantity]
,[produto].iskit as [explodir]
FROM
FilteredProduct AS [produto]
INNER JOIN
FilteredQuoteDetail AS [linha]
ON [produto].productid = [linha].productid

WHERE
[linha].quoteid = @quoteid

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Prefiltering not working - Sql query

    First, not sure which CRM version you are using. I test your query in CRM 2013 and it is not work the first time with CRMAF. I run the report from a product and I get all products as the result.

    Then I change you alias table name. The important part is the table name should be same as CRM table except CRMAF part. I run the new report and it only return the selected product in the report.

    Please check and let me know if this fix works for you.

    my query is something like below:

    SELECT

    CRMAF_Product.productid AS [productid]

    ,CRMAF_Product.productnumber AS [productnumber]

    ,CRMAF_Product.name AS [productname]

    ,CRMAF_Product.description AS [description]

    ,CRMAF_QuoteDetail.priceperunit as [price]

    ,CRMAF_QuoteDetail.tax as [tax]

    ,cast(CRMAF_QuoteDetail.quantity as decimal) as [quantity]

    ,CRMAF_Product.iskit as [explodir]

    FROM

    FilteredProduct AS CRMAF_Product

    INNER JOIN

    FilteredQuoteDetail AS CRMAF_QuoteDetail

    ON CRMAF_Product.productid = CRMAF_QuoteDetail.productid

  • Verified answer
    HenriquePalomo Profile Picture
    510 on at
    RE: Prefiltering not working - Sql query

    I figured out the problem by creating another project and data set. Now i can see the prefiltering working on DataSet query in visual studio and on CRM.

    Thx for help.

  • HenriquePalomo Profile Picture
    510 on at
    RE: Prefiltering not working - Sql query

    I forgot to say that i used the same query, i just created the dataset / project.

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier 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