Power Apps Exchange

Please login or click SIGN UP FOR FREE to create your PowerAppsUG account to join this user group.
 View Only
  • 1.  Issue with PATCH function to a SQL database

    Posted Nov 08, 2022 03:45 PM
    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.

                              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

                         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

  • 2.  RE: Issue with PATCH function to a SQL database

    Silver Contributor
    Posted Nov 09, 2022 03:43 PM

    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

  • 3.  RE: Issue with PATCH function to a SQL database

    Posted Nov 11, 2022 04:31 PM

    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(
                          SortByColumns(Filter(Parts, PartNumber= txtLEPartNo_1.Text),
                          "Revision", Ascending),1
            UpdateContext({varRevisionEntered: txtLERevision_1.Text});
            UpdateContext({varLastRevision: txtLERevision_1.Text});

    Thanks for the help.

    John Heck