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
Super User
Super User

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
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 (3,679)