After "exercising" with PowerApps in combination with Dynamics 365 CRM for 1.5 days, I'm turning to this community for advice. Admittedly I'm a beginner with PowerApps, but have few years of experience with Dynamics 365 (CRM).
So, what I'd like to achieve is to have 2 screens in a Canvas App:
Screen 1: Contacts Gallery with filtering and ability to select a Contact
Screen 2: All related Activities for the Contact selected on Screen 1.
Activities in CRM are related to Contacts (and other types Activity Parties) via N:N relationship. I don't mean the "Regarding" field here.
Screen 1 - no problem, this works and works well.
Screen 2 - this is where I'm stuck.
I can query and show ALL Activities in a datatable or a gallery, this works, no problem with this.
But I can't figure out a way how to apply a filter to the Activity gallery so that only those that are related to the specific Contact are shown.
I think (correct me if I'm wrong) that the only way to achieve this is to use Flow (Power Automate), it seems to me that there is no way to do this directly in PowerApps. At least I could not find a way to do this in PowerApps.
In Flow itself I can get the filtered list via CDS (Current Environment) get List of Records when using the FetchXML box to specify a fetchxml query. But Canvas App is rejecting the CDS (Current Environment) Flow ("failed during http send request"), so this seems to be a no-go option.
How would you approach this, any tips?
The idea seems to be very simple: pick a contact and see his related Activities. But when N:N relationship comes into play, things seem to become very complicated.
Thank you very much in advance for your advice.
Hi @Lauris ,
Do you want to filter Activities records based on the selected Contact record in your first Gallery?
Based on the needs that you mentioned, I think the PowerApps could achieve your needs. I have made a test on my side, please consider take a try with the following workaround:
Set the Items property of Gallery1 to following:
Set the Items property of Gallery2 to following (without applying Filter function in Activities Entity😞
then these activities related to selected Contact would be displayed within the Gallery2.
Please check and see if the following blog would help in your scenario:
Hi@v-xida-msft and thank you so much for ideas.
So, the scenario you proposed works for Activities where the Regarding field is set to the respective Contact. This works well and no questions here. And I did a fresh test just now after your kind advice. This scenario works fantastically with 1:N relationships.
But the real sales/CRM life as far as I've experienced is such that Activities are typically Regarding something like an Opportunity a Case or some other Entity while Contacts are typically the N:N related Activity parties; emails in many cases are between many people. So we have to look at N:N relationships.
So ... unless I missed something from your advice (and I apologize for inattentiveness if so), we have to go some other way.
I looked at the blog post and it seems that it's the right direction. Two things I can't understand from that post:
1) Do I understand correctly that the mentioned "In CDS we can create Students and Teachers entities and relate them through a Many-to-Many relationship" means that a separate N:N relationship is meant to be created in CDS/PowerApps, that lives only in the PowerApp and is separate from CRM existing N:N relationship between Contacts and Activities?
2) Where exactly can I get to this screen (see pic attached) of creating the relationships? Is it in PowerApps?
Why do you imply that @v-xida-msft suggestion doesn't work for 1:N relationship and only work for N:N relationships? We did test on our side and when we set the sub-gallery Items to
For us it worked for N:N relationship, so we did not understand why you claim it did not work for N:N relationship?
We would like to note that when building with CDS Entity, we were not allowed to do as follows in available testing environment using a pretty recent (probably newest) version of CDS:
Therefore we could only try scenario on two custom entities only, and both non-Activity type, and both had N:N relationship (to each other).
The above scenario that was outlined by @v-xida-msft worked when we tested from our side.
We do not know if because it's an Activity entity that it may affect it in your case - this we do not know for sure.
However the blanket claim that @v-xida-msft suggestion work for 1:N but not N:N is not correct from our side. We tested and it works for N:N to do this way.
Hi @poweractivate and thank you very much for your valuable input!
Well, you might be right in that Activities are "special". Even more so because Activity entity is comprised of the separate Email, Task, PhoneCall etc. Nevertheless, the aim is to achieve visualising list of these related Activities.
So, here I just did a real life test with 2 scenarios:
Test A: email with Contact in "Regarding" field, i.e. 1:N relationship
Test B: email with Contact in "To" field, i.e. N:N relationship but the Regarding field is empty.
With Test A - the Activity shows up in the second gallery in PowerApps without any issues.
With Test B - the Activity does not show up in the second gallery in PowerApps.
As soon as I indicate Regarding field in Test B email, the email shows up as Activity in PowerApps second gallery as expected. If I remove Contact from the Regarding field in email and only leave him in the "To" field, the Test B email disappears from that gallery.
Below are screenshots from my tests. For the sake of simplicity I put both Galleries on the same screen.
@poweractivate would it be too much to ask you to do such test specifically with Activities on your side? I know this is free community advice so it will be totally understandable if you say no...
Thanks again so much for spending time with me.
Check out new user group experience and if you are a leader please create your group
Next call is happening on April 21st at 8a PST.
May the fourth be with you, join us online!
See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.