I am making a Power App where a user inserts machine information into a form, and then click a button to save it. It is also supposed to log this query alongside the date.
I wanted the patch function to look at the data card values and patch those into a table, under a new record with the current date. UNIT, LOG, and MACHINE are column values that can either be typed in or not changed. The rest are all dropdown fields. I'm getting a few different errors and I'm not really sure how to address them.
The table or source changes depending on a button that the user clicks earlier in the navigation. It's a variable that gets set to a different table depending on the button pressed.
Here's the formula for the patch:
Patch(
table_archive,
Defaults(table_archive), {
UNIT: dcv_unit.Text,
MACHINE: dcv_machine.Text,
SOFTWARE: dcv_software.Selected,
PC: dcv_pc.Selected,
USER: dcv_user.Selected,
LOG: dcv_log.Text,
DATE: Today()
});
SubmitForm(form_machinedetail);
Navigate(screen_success);
These are the errors:
I want to just add a new record/copy to the archive table while it updates the original source table. I can't seem to understand Patch too well, but I would appreciate if someone could point me in the right direction. Thank you in advance.
The Selected
property of a dropdown control will give you the entire record that was selected. For example, you can set this expression as the Items property of a dropdown:
[{Name:"John Doe",Age:33},{Name:"Jane Roe",Age:32},{Name:"Joan Coe",Age:34}]
And if the first item is selected, the value of dropdown.Selected
will be the record {Name:"John Doe",Age:33}
which has 2 scalar properties (Name and Age).
The PC/USER columns in your Excel table need a single (scalar) value (such as a text value or a numeric one), but when you mention PC: dcv_pc.Selected
you are passing the entire selected record to it. To fix this problem, you will need to select the property of the record that needs to be passed to the Excel table, such as ... PC: dcv_pc.Selected.Value, USER: dcv_user.Selected.Value, ...
. If you type .
after dcv_pc.Selected
the intellisense should show you the actual column names that you can select.