Koen,
Thanks for the reply. txtLEPartNo_1.Text is a text field formatted like 7122-067S and the txtLERevision_1.Text is a single letter, ie A B C D E, etc. Both of the entry fields are Text Input fields on the screen. I seem to be only having issues in this one sport and one other i just found out. The other slice of code is below where something similar is happening in that it knows whether or not the If statement is true or false though it doesn't update the varRevisionEntered or the varLastRevision fields with the associated text values.
If(IsEmpty(LookUp(Parts, PartNumber = txtLEPartNo_1.Text && Revision = txtLERevision_1.Text)),
UpdateContext({varRevisionEntered: txtLERevision_1.Text});
UpdateContext({varLastRevision: Last(
LastN(
SortByColumns(Filter(Parts, PartNumber= txtLEPartNo_1.Text),
"Revision", Ascending),1
)
).Revision
}),
UpdateContext({varRevisionEntered: txtLERevision_1.Text});
UpdateContext({varLastRevision: txtLERevision_1.Text});
);
Thanks for the help.
------------------------------
John Heck
------------------------------
Original Message:
Sent: Nov 09, 2022 03:42 PM
From: Koen Mathijs
Subject: Issue with PATCH function to a SQL database
John,
can you show us what exactly is in PartNumber after you do your ClearCollect routine?
It's not clear to me what this field should contain because you do some sort of filtering on it (PartNumber = txtLEPartNo_1.Text && Revision = txtLERevision_1.Text)
From the error message I get that a Text field is required (as it should because you declared it as a "nvarchar") but actually some sort of error message is captured (The type of this argument 'PartNumber' does not match the expected type 'Text'. Found type 'Error'.)
It looks like you are trying to Patch an error message in a text field and that's why the Patch command is giving you this error.
I could be way off but at this moment this is my best guess. Try to look at the content of PartNumber before you patch it
------------------------------
Koen Mathijs
Original Message:
Sent: Nov 08, 2022 03:45 PM
From: John Heck
Subject: Issue with PATCH function to a SQL database
Using the Patch function to write data to a SQL table. When I create the patch function no matter what fields I use I get the error message
The type of this argument 'PartNumber' does not match the expected type 'Text'. Found type 'Error'.
The function 'PATCH' has some invalid arguments.
PartNumber is a nvarchar(50) in both SQL tables, PartAttribute & PartAttributeTable. Both tables have a Primary Key set.
Here is the code that I am working with.
ClearCollect(
colPAT,
ShowColumns(
Filter(
PartAttribute, PartNumber = txtLEPartNo_1.Text && Revision = txtLERevision_1.Text
),
"ID", "PartID", "PartNumber", "Revision", "SequenceNumber", "Diamond", "Attribute", "LowerLimit", "LLUnits", "UpperLimit", "ULUnits"
)
);
// this code needs to be fixed
ForAll(
colPAT,
Patch(
PartAttributeTable,
Defaults(PartAttributeTable),
{
PartNumber: PartNumber // this is the line that receives the error. 1st PartNumber is in the PartAttributeTable and the 2nd one is in the colPAT from above.
}
)
);
At one time I had this working and I needed to add a couple of new fields to the PartAttributeTable. After adding the additional fields I did remove the table from the PowerApps and brought it back in. Everything on the screen works fine and there are no errors with any other area that uses fields from the PartAttributeTable.
Thanks in advance for your assistance.
------------------------------
John Heck
------------------------------