Skip to main content

Notifications

Community site session details

Community site session details

Session Id : LS/jYOjjctWRdYo4mfckV6
Power Apps - Microsoft Dataverse
Unanswered

Dynamics 365 Model driven app -SSRS FetxhXML report passing selected/opened record id

Like (0) ShareShare
ReportReport
Posted on 5 Nov 2021 21:04:00 by 120

I have a FetchXML based SSRS report. Which is supposed to show activities at account level. 

My client requirement is to execute this report on an open account record by selecting the report from the ribbon. I have tried to parametrise the report but no luck. Highlighted red below.

How do I pass the open/selected record ID to the report so it executes in the context of that record?

<?xml version="1.0"?>

<fetch distinct="true" mapping="logical" enableprefiltering="true" output-format="xml-platform" version="1.0">

<entity name="activitypointer">

<attribute name="activitytypecode"/>

<attribute name="subject"/>

<attribute name="statecode"/>

<attribute name="prioritycode"/>

<attribute name="modifiedon"/>

<attribute name="activityid"/>
<attribute name="scheduledstart" />
<attribute name="scheduledend" />
<order descending="true" attribute="modifiedon"/>
<link-entity name="activityparty" alias="aq" link-type="inner" to="activityid" from="activityid">
<filter type="and">

<condition attribute="participationtypemask" operator="in">

<value>1</value>
<value>2</value>

<value>3</value>
<value>4</value>
<value>5</value>
<value>6</value>
<value>7</value>
<value>8</value>
<value>9</value>
<value>11</value>

</condition>
</filter>
<link-entity name="contact" alias="con" link-type="inner" to="partyid" from="contactid">
<attribute name="fullname"/>
<attribute name="parentcustomerid"/>
<attribute name="jobtitle"/>
<link-entity name="account" alias="acc" link-type="inner" to="parentcustomerid" from="accountid">
<attribute name="name"/>

<filter type="and">
<filter type="or">
<condition attribute="accountid" operator="eq" value="@CRMID"/>

<condition attribute="parentaccountid" operator="eq" value="@CRMID"/>

</filter>

</filter>

</link-entity>

</link-entity>

</link-entity>

</entity>

</fetch>

 

Run report on the opened record

 

UmerJaved_1-1636146008544.png

 

UmerJaved_2-1636146057076.png

Thanks

 

Categories:
  • Mira Ghaly Profile Picture
    11,409 Super User 2025 Season 1 on 07 Nov 2021 at 20:57:33
    Re: Dynamics 365 Model driven app -SSRS FetxhXML report passing selected/opened record id

    @UmerJaved 

     

    So as @rampprakash  you need to define a new dataset to the account , called Accounts  as below:

    SELECT        accountid
    FROM            FilteredAccount AS CRMAF_FilteredAccount

    Then on your report add a Parameter for the accountid as below:

    Mira_Ghaly_0-1636318597672.png

     

    Then pass the parameter to your fetchXML as below:

     

    <?xml version="1.0"?>
    
    <fetch distinct="true" mapping="logical" enableprefiltering="true" output-format="xml-platform" version="1.0">
    
    <entity name="activitypointer">
    
    <attribute name="activitytypecode"/>
    
    <attribute name="subject"/>
    
    <attribute name="statecode"/>
    
    <attribute name="prioritycode"/>
    
    <attribute name="modifiedon"/>
    
    <attribute name="activityid"/>
    <attribute name="scheduledstart" />
    <attribute name="scheduledend" />
    <order descending="true" attribute="modifiedon"/>
    <link-entity name="activityparty" alias="aq" link-type="inner" to="activityid" from="activityid">
    <filter type="and">
    
    <condition attribute="participationtypemask" operator="in">
    
    <value>1</value>
    <value>2</value>
    
    <value>3</value>
    <value>4</value>
    <value>5</value>
    <value>6</value>
    <value>7</value>
    <value>8</value>
    <value>9</value>
    <value>11</value>
    
    </condition>
    </filter>
    <link-entity name="contact" alias="con" link-type="inner" to="partyid" from="contactid">
    <attribute name="fullname"/>
    <attribute name="parentcustomerid"/>
    <attribute name="jobtitle"/>
    <link-entity name="account" alias="acc" link-type="inner" to="parentcustomerid" from="accountid">
    <attribute name="name"/>
    
    <filter type="and">
    <filter type="or">
    <condition attribute="accountid" operator="eq" value="@accountid"/>
    
    <condition attribute="parentaccountid" operator="eq" value="@accountid"/>
    
    </filter>
    
    </filter>
    
    </link-entity>
    
    </link-entity>
    
    </link-entity>
    
    </entity>
    
    </fetch>

     

     

     

  • UmerJaved Profile Picture
    120 on 07 Nov 2021 at 16:08:20
    Re: Dynamics 365 Model driven app -SSRS FetxhXML report passing selected/opened record id

    Hi @Mira_Ghaly 

     

    Our Accounts are not directly linked with the activities. In other words we do not set "Regarding" for activities to accounts instead "Contact" or "opportunities" hence above query won't work for us. the query which I have provided in the original thread works perfectly when testing using FetchXML tester/Or query designer in SSRS, its only the filter in report we need to sort out.i.e. run in the context of opened/selected record...

     

    Thanks

  • Ram Prakash Profile Picture
    5,166 Super User 2025 Season 1 on 07 Nov 2021 at 15:43:35
    Re: Dynamics 365 Model driven app -SSRS FetxhXML report passing selected/opened record id

    Hello @UmerJaved,

     

    You are too close to achieve the same, try creating a new Data Set in the SSRS

     

    SELECT        accountid
    FROM            FilteredAccount AS CRMAF_FilteredAccount

     

    Passed this as a parameter to the first dataset. By doing the id of the opened record to the report as parameter.

     

    Please mark as Answer if it is helpful and provide Kudos


    Subscribe : https://www.youtube.com/channel/UCnGNN3hdlKBOr6PXotskNLA
    Blog : https://microsoftcrmtechie.blogspot.com

  • Mira Ghaly Profile Picture
    11,409 Super User 2025 Season 1 on 05 Nov 2021 at 21:42:59
    Re: Dynamics 365 Model driven app -SSRS FetxhXML report passing selected/opened record id

    @UmerJaved 

    For the prefiltering to work correctly , the dataset or your fetchXML needs to be based on the Account and Linked to the Activities , if you can try the below Fetch Instead it should work, the below fetch is supposed to return all activities regarding the account:

    Please also Note I have given the Link-Entity an Alias "Account Activities" for each of use:

    
    <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true" enableprefiltering="1" >
     <entity name="account" >
     <attribute name="name" />
     <attribute name="primarycontactid" />
     <attribute name="telephone1" />
     <attribute name="accountid" />
     <order attribute="name" descending="false" />
     <link-entity name="activitypointer" from="regardingobjectid" to="accountid" link-type="inner" alias="accountactivities" >
     <attribute name="activitytypecode" />
     <attribute name="subject" />
     <attribute name="statecode" />
     <attribute name="prioritycode" />
     <attribute name="modifiedon" />
     <attribute name="activityid" />
     <attribute name="scheduledstart" />
     <attribute name="scheduledend" />
     <order descending="true" attribute="modifiedon" />
     </link-entity>
     </entity>
    </fetch>

     

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,776 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,093 Most Valuable Professional

Leaderboard

Featured topics