cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Digdem
Frequent Visitor

Invalid argument type (Table). Expecting a Record value instead.

Hi all, 

 

I made the same app as the link below and everything worked fine untill I wanted to patch my data. The patch functions gives an error called "Invalid argument type (Table), Expecting a Record value instead. How can I solve this? 

 

Power Apps Editable Table/Gallery like Excel (Tutorial) - YouTube

 

App OnStart I have: 

ClearCollect(colTaskUpdates,  

    Defaults('Customer VAT') 

; 
Clear(colTaskUpdates) 
) 

 

In a gallery variable I have OnSelect: 

If(
    ThisItem.'Customer VAT ID' in colTaskUpdates.cr99c_customervatid,
    Update(
        colTaskUpdates,
        LookUp(
            colTaskUpdates,
            cr99c_customervatid = ThisItem.'Customer VAT ID'
        ),
        {
            cr99c_customervatid: ThisItem.'Customer VAT ID',
            cr99c_invoicenumber: InvoiceNumber_1.Text,
            cr99c_nettinvoiceamount: NettInvoiceAmount_1.Text,
            cr99c_vatamount: VATAmount_1.Text,
            cr99c_invoicedate: InvoiceDate_1.Text,
            cr99c_buyer: Buyer_1.Text,
            cr99c_countrycodebuyer: CountryCodeBuyer_1.Text,
            cr99c_vatidnumberbuyer: VATIDNumberBuyer_1.Text
        }
    ),
    Collect(
        colTaskUpdates,
        {
            cr99c_customervatid: ThisItem.'Customer VAT ID',
            cr99c_invoicenumber: InvoiceNumber_1.Text,
            cr99c_nettinvoiceamount: NettInvoiceAmount_1.Text,
            cr99c_vatamount: VATAmount_1.Text,
            cr99c_invoicedate: InvoiceDate_1.Text,
            cr99c_buyer: Buyer_1.Text,
            cr99c_countrycodebuyer: CountryCodeBuyer_1.Text,
            cr99c_vatidnumberbuyer: VATIDNumberBuyer_1.Text
        }
    )
)

 

The save button OnSelect has 

If( 

    CountRows(colTaskUpdates) > 0, 
    Patch( 
        'Customer VAT ID', 
        colTaskUpdates 
    ); 

    Notify( 
        "Succees", 
        NotificationType.Succees 
    ) 
); 

Clear(colTaskUpdates) 

 

In dataverse the data types of the following variables are: 

cr99c_customervatid: Unique Identifier
cr99c_invoicenumber: Text
cr99c_nettinvoiceamount: Currency
cr99c_vatamount: Currency
cr99c_invoicedate: Date Only
cr99c_buyer: Text
cr99c_countrycodebuyer: Text
cr99c_vatidnumberbuyer: Text

 

@Reza 

7 REPLIES 7
v-bofeng-msft
Community Support
Community Support

Hi @Digdem ,

 

You could try:

If( 

    CountRows(colTaskUpdates) > 0, 
    Collect( 
        'Customer VAT ID', 
        colTaskUpdates 
    ); 

    Notify( 
        "Succees", 
        NotificationType.Succees 
    ) 
); 

Clear(colTaskUpdates)

 

Best Regards,

Bof

Hi @v-bofeng-msft ,

 

Thank you so much for your help. I changed my formula and the error messages are gone, however the data in dataverse is not changed. 

 

When I make changes in my gallery this is saved in my collection and when I click on "save" button the collection items should overwrite existing items in dataverse. This is currenty not the case. Do you know how to solve this? 

 

@EricRegnier @dpoggemann @ChrisPiasecki 

Digdem
Frequent Visitor

dpoggemann
Super User
Super User

Hi @Digdem ,

Overall your code looks good to me.  My main concern is how you are populating some of the fields, maybe I am wrong but don't you need to convert?  Example your date field, wouldn't you need to populate the date field with a Date (https://docs.microsoft.com/en-us/power-apps/maker/canvas-apps/functions/function-datevalue-timevalue)  and for your currency something like:

Currency:Value(TextInput2.Text)

Sorry, don't do a ton with Canvas apps but this is what jumped out to me.  

Hope this helps. Please accept if answers your question or Like if helps in any way.
Thanks,
Drew

Hi @Digdem, this you get this working afterall?  By "should overwrite existing items in dataverse" do you mean the items can created instead of updating. To update you can use Patch function and if you're using a form, try SubmitForm function to create/update. Hope this helps!

I mean the items can update. 

@Digdem, thanks. Did you try the SubmitForm as per my previous post? This should work nicely and it's simply assuming you have a Edit form control (if not, suggest you have one). Cheers

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (2,409)