Choose your path Increase your proficiency with the Dynamics 365 applications that you already use and learn more about the apps that interest you. Up your game with a learning path tailored to today's Dynamics 365 masterminds and designed to prepare you for industry-recognized Microsoft certifications.
Visit Microsoft Learn
2020 release wave 1Discover the latest updates and new features to Dynamics 365 planned through September 2020
Release overview guides and videos Release Plan | Preview 2020 Release Wave 1 Timeline
Ace your Dynamics 365 deployment with packaged services delivered by expert consultants. | Explore service offerings
Connect with the ISV success team on the latest roadmap, developer tool for AppSource certification, and ISV community engagements | ISV self-service portal
The FastTrack program is designed to help you accelerate your Dynamics 365 deployment with confidence.
FastTrack Program | Finance TechTalks | Customer Engagement TechTalks | Upcoming TechTalks
I have a report that runs on selected Account records. You can check off certain Account records, and the report returns a list of Contacts associated with those Accounts (along with some other stuff, like certain Connections associated with those contacts).
This is currently working, but I would like to expand the report so you could run it by directly selecting the Contacts you want to see relationships for, rather than just by selecting their Accounts. It would also be nice to run this by selecting a Marketing List. Is there a way I could expand what I have so it can accept different types of records and alter my dataset logic based on the type of record it is being run on?
I based my report off this blog post, although I made some changes: http://www.kentom.co.uk/?p=353
I have a Main Report that is Fetchxml based. It takes the account records you have selected and passes the accountid as a parameter to a Subreport. (Unlike the blog post, my Subreport is actually SQL based, because I need to use unions and temp tables.) I won't bother to explain everything the subreport does, but for the sake of simplicity, let's just says my dataset in the subreport is:
Select * from contacts where accountid = @accountid
I'd like to make changes to my main report so it can accept different types of IDs, and will let me know which kind of record is being used. That way, my dataset in the Subreport could be something like this:
If (@recordType = 'Account')
Select * from contacts where accountid = @recordID
Else if (@recordType = 'Contact')
Select * from contacts where contactid = @recordID
Currently, this is what my Main Report looks like. What changes would I need to make to get something similar to the input I need to run the dataset in my Subreport?
<fetch distinct="false" mapping="logical" output-format="xml-platform" version="1.0"><entity name="account" enableprefiltering="1"><attribute name="accountid"/></entity></fetch>
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false"><entity name="account"><all-attributes/></entity></fetch>
Link to Subreport:
Sends as a parameter the "accountid" field from the dataset
Any help would be greatly appreciated. Thank you!
Just wanted to try to bump this question before I give up on it and just create two separate reports. I have tried several approaches which have been unsuccessful. Does anyone have any ideas/suggestions?
Thanks very much for your response. I apologize for my lack of knowledge of Fetch, I'm very new to this. I think i need a little more advice about how to use the code you provided above. Could you please explain more explicitly what I should do with that code?
My initial thought was that you intended that I could use that code to identify the type of entity that was selected. If that's correct, I'm unsure how to use it in that way.
Here is what I tried:
I tried creating a new parameter, with that code above as the default value. I thought that this would return the entity name (like "contact" or "account"). But the parameter seems to just return the text of the code, rather than the executed value as I had hoped. I'm not sure how to create a parameter that executes fetch code within it, and I could not find explanation of how to do this elsewhere. (The parameters I listed above that are like this were created automatically based on my dataset code).
I tried creating a dataset with an altered version of your code:
<fetch distinct="false" mapping="logical" output-format="xml-platform" version="1.0">
<entity name="incident" enableprefiltering="1" prefilterparametername="CRM_FilteredIncident">
It gives me an error when I try to save the dataset, saying The attribute "entityname" cannot be found for the entity "incident"
I looked up the entity "incident", and I am not understanding what it has to do with what I am trying to do here. Did you mean that just as an example, and I am supposed to change it to another entity?
how did you solve this error?
I apologize for the delay in response. I am a bit confused because it looks like you have either edited your initial response, or I was absolutely confused at the time I responded and was reading something completely different. In any case, my response above seems to not be relevant to the link you have provided.
This is a good idea, however, I have a limited role at this organization. I am allowed to create reports, but I don't think they want me creating any custom buttons. So unfortunately, I'm unable to try this method.
The solution I eventually decided on was to create two almost identical reports, both with the same name. The only difference one is designed to run on contacts, the other on accounts.
Since they have the same name, and each is configured to only appear in the proper context (either for contacts, or accounts, using the "Related Record Types" option), the user doesn't need to know that they are actually different reports.
I usually try not to replicate code in two places like this, but it was the best solution I was able to implement. Thanks for your help.
Thanks Ben for your response. It helped me
Business Applications communities