Hi,
I'm fairly new to PowerApps, getting to grips with it and liking it the more I learn. However I'm a bit stuck on a requirement I've been given and hope someone can help me out.
We have 2 tables in separate DB's in SQL. One table contains our customers profile (CustomerProfiles) and the other table contains our customers with all the roles of employees (RolesForCustomers) for each of these customers, such as Field Sales, BDM etc. The two tables share a field called PartyNumber that is the customers unique ID.
CustomerProfile (my main table)
- PartyNumber
- Customer Name
- Customer Address etc
RolesForCustomers (Secondary table)
- PartyNumber
- BDM
- Credit Controller etc
On the Browse Screen I would like to present the currently logged in user with a link to the CustomersProfile record, but I only want to display customers where the currently logged in user exists in one of the roles in RolesForCustomers.
So far I've come up with this for the BrowseGallery
SortByColumns(Filter(AddColumns('CustomersProfile]', "BDM", LookUp('RolesForCustomers', PartyNumber = PartyNumber, BDM)),User().FullName = "BDM"), "CustomerName", If(SortDescending1, Descending, Ascending))
However, in the options for the BrowseGallery, it's showing me the RolesForCustomers datasource instead of the CustomersProfile datasource. So clearly I've got something wrong here.
As I understand it, the AddColumns function allows me to add a "calculated" column to the named datasource, The Lookup is then looking at the RolesForCustomers table to match the PartyNumber ID from the two tables and bring back the BDM column. and then compare the value of the currently logged in user against the BDM column and return all rows where they match.
In time I'd like to increase this to be adding other columns as well (Credit Controller, Field Sales Rep etc), but for now, just getting it working with the one column would be a win for me.
I've followed this blog so far, but clearly I'm not translating it quite to my requirements.
http://www.crmviking.com/2017/02/using-related-entities-in-powerapps.html
Thanks in advance for any help you can provide.