cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Mia17
New Member

Error (Patch, UpdateIf, RemoveIf) - Invalid Argument(Table) Expecting a record value instead

I want to walk through the gallery, and check if an condition is true, insert a row of data to the database, else update an existing data.

 

I use an If() in ForAll(), and I found that if I use

If( condition, UpdateIf() , Patch() ),  it works

 

But if I change the sequence, it shows error

If( condition , Patch(), UpdateIf() )

 

Then, I try a few combination, some work but some show error.(see pictures below)

 

I don't know what the logic is and feel really confused.

Could someone please tell me?

Thanks so much.

 

Works Error
FirstNext FirstNext
UpdateIf()Patch()_insert Patch()_insertUpdateIf()
UpdateIf()RemoveIf() Patch()_insertRemoveIf()
RemoveIf()Patch()_insert UpdateIf()Patch()_update
RemoveIf()UpdateIf() RemoveIf()Patch()_update
Patch()_updatePatch()_insert   
Patch()_updatePatch()_update   
Patch()_insertPatch()_update   
Patch()_insertPatch()_insert   

 

==================== Work ====================

// UpdateIf(), Patch()_insert
ForAll(gal_education_3.AllItems As tmp,
    If(IsBlank(tmp.serial),
        UpdateIf(EducationInfo, serial=tmp.serial, {nation:tmp.nation})
        ,Patch(EducationInfo, Defaults(EducationInfo), {nation:tmp.nation})
    )
);

 

==================== Error ====================

ForAll(gal_education_3.AllItems As tmp,
    If(IsBlank(tmp.serial),
        Patch(EducationInfo, Defaults(EducationInfo), {nation:tmp.nation})
        ,UpdateIf(EducationInfo, serial=tmp.serial, {nation:tmp.nation})
    )
);

 

Mia17_0-1634103251515.pngMia17_1-1634103270183.png 

 

Mia17_3-1634104286009.png

 

Mia17_4-1634104327961.png

 

5 REPLIES 5
shoog
Solution Supplier
Solution Supplier

What datatype is the serial property of EducationInfo?

It's integer

WarrenBelz
Super User
Super User

Hi @Mia17 ,

In your UpdateIf where the error is you have {nation:temp.nation} instead of nation=tmp.nation

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

I am not sure I do you mean.

I set the ForAll items to tmp, so I use {nation:tmp.nation}

I didn't use {nation:temp.nation}😕

@Mia17 ,

OK - I see it now - please disregard my previous post.

I have tested both here and they work either way (so I cannot replicate your issue), but simply use !IsBlank(tmp.Serial) and put them the way that works for you.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,441)