I have an Azure SQL database as my source for both form data and Dropdown box data. There are 2 screens, one with a gallery which has a view from the SQL database as its source, which displays details (including the record ID) and another screen which contains a form that can be switched to Display/Edit/New.
When a user clicks an arrow icon on the first form, it sets a variable to an ID: Set(var_sd_id,ThisItem.sd_id).
The second screens form has a DataSource: '[metadata].[source_destination]' and uses the variable var_sd_id to filter it's record. The forms Item property is: First(Filter('[metadata].[source_destination]',sd_id=var_sd_id))
The above seems to work fine, a record is selected on the second screen form after clicking the arrow icon on the first.
However, I have created a number of Dropdown Boxes on the form. These appear to be set up correctly, they are in data cards and have the following settings for a field named "source_system_id", which is simply a FK-PK lookup to a table named "metadata.storage_system":
Card:
The Dropdown Box properties are:
The problem comes when I open the form. The Dropdown box reverts back to the first record in the storage_system table, instead of the ID specified in the source_destination table. I have looked for similar errors, many talk about the DefaultSelectedItems value, but I don't have that Setting to change (I assume it have been renamed to "Default"?).
I have also turned off the "Delayed Load" setting, which has changed the behaviour slightly but not changed this problem.
If I set the Value setting of the Dropdown box to system_id, the Dropdown box no longer reverts to the first item. However I do not want the system_id to be displayed, I want the easy_name recorded in the source system table.
Any ideas?
Solved! Go to Solution.
I fixed this myself, though I cannot seem to see anyone else solving this on this site for drop downs. So I will post the solution here. People should understand - this means I can use a drop down box based on SQL PK-FK relationships, just as you can in most other applications. The drop down uses the data in the PK side and returns the PK ID which is saved in the FK field. (PK = Primary Key, FK = Foreign Key).
The following works for View, Edit and New form settings. For New, the Drop Down boxes appear as blank, which is good, because it picks up on default error handling when you create a form. This means you don't need to put in custom error messages etc, you can use the default PowerApps ones when you create a form. This also doesn't rely on creating Collections and re-storing the data in the PowerApps application. It does require creating a few variables, but that's not abnormal or difficult.
My application uses a gallery on one screen used to view the data (now referred to as View screen). An arrow icon is then used in the gallery to open the View/Edit/Add Screen (now referred to as Edit screen). The Edit screen has a form on it, with fields added as normal using the "Edit Fields" link in the properties. The Edit screen also has an Edit/Add and Save buttons.
When the user clicks the arrow icon from the gallery on the View screen, it does 3 things:
So far so good, the Edit screen is opened to "View" with the record selected on the form in View mode. However using Drop Down defaults, the issue I describe above occurs. So lets modify the View Screen. Note the form on the View screen is named "frmSourceDestination":
I can now have drop downs linked to the PK table(s) which force selections for editing and new records. In my case this is better than the closest solution (which is still good) I found here: https://www.youtube.com/watch?v=iayXCMFZ_CE
I fixed this myself, though I cannot seem to see anyone else solving this on this site for drop downs. So I will post the solution here. People should understand - this means I can use a drop down box based on SQL PK-FK relationships, just as you can in most other applications. The drop down uses the data in the PK side and returns the PK ID which is saved in the FK field. (PK = Primary Key, FK = Foreign Key).
The following works for View, Edit and New form settings. For New, the Drop Down boxes appear as blank, which is good, because it picks up on default error handling when you create a form. This means you don't need to put in custom error messages etc, you can use the default PowerApps ones when you create a form. This also doesn't rely on creating Collections and re-storing the data in the PowerApps application. It does require creating a few variables, but that's not abnormal or difficult.
My application uses a gallery on one screen used to view the data (now referred to as View screen). An arrow icon is then used in the gallery to open the View/Edit/Add Screen (now referred to as Edit screen). The Edit screen has a form on it, with fields added as normal using the "Edit Fields" link in the properties. The Edit screen also has an Edit/Add and Save buttons.
When the user clicks the arrow icon from the gallery on the View screen, it does 3 things:
So far so good, the Edit screen is opened to "View" with the record selected on the form in View mode. However using Drop Down defaults, the issue I describe above occurs. So lets modify the View Screen. Note the form on the View screen is named "frmSourceDestination":
I can now have drop downs linked to the PK table(s) which force selections for editing and new records. In my case this is better than the closest solution (which is still good) I found here: https://www.youtube.com/watch?v=iayXCMFZ_CE
User | Count |
---|---|
205 | |
94 | |
87 | |
47 | |
43 |
User | Count |
---|---|
252 | |
104 | |
103 | |
61 | |
57 |