web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / mdevaney - Invalid arg...
Power Apps
Answered

mdevaney - Invalid argument type

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi @mdevaney, sorry I tried to edit the last post and it got marked as spam. It keeps happening!

 

I've copied the original post into here and added the image below.

I have a gallery which shows the steps of a process. Selecting an item in the gallery fetches and displays the step record (which is stored in record variable varThisStep).

 

Each item in the gallery has a "Complete" field, which is boolean. I have a 'Mark Complete' button which, when Complete is false for the current item, Patches the item's complete field to true and sets varThisStep to the next item in the gallery. I would also like this button to 'Mark Incomplete' when Complete is true. In this case, there will be no change to varThisStep.

 

Here is my formula:

 

With(
 {
 thisstep: LookUp(colProcessSteps, StepID = varThisStep.ID)
 },
 With(
 {
 nextstepnumber: thisstep.StepNumber + 1
 },
 With(
 {
 nextstepid: LookUp(colProcessSteps, StepNumber = nextstepnumber).StepID
 },
 If(
 thisstep.Complete,
 Patch(colProcessSteps, thisstep, {Complete: false}),
 Patch(colProcessSteps, thisstep, {Complete: true});
 Set(varThisStep, LookUp(BusinessProcessSteps, ID = nextstepid))
 )
 )
 )
)

 

 

I'm getting red squiggles under the semicolon after the second patch and the error is:

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

 


Removing the Set() fixes it. What is it about the Set that it doesn't like?

 

Thank you!

Joel

Categories:
  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    I see this is a message from another thread, but I thought I might add a little to the conversation.

     

    If Statements within a With statement can give erroneous results to the designer (but will not work).

    As a workaround, I often will include yet another With for the Patch statement.  They are dummy With's but they resolve the issue - which is that once you set up a with and do a patch in them, it then expects a certain return result from within the with.  If you have an If with multiple dissimilar statement return results you will see this issue.

     

    Try to encapsulate your Patches like this:

    With({xx:Patch(colProcessSteps, thisstep, {Complete: false})}, true)

    The true is important.

     

    Hope it helps.

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @RandyHayes  I don't know why it works........but it does! 

     

    With(
     {
     thisstep: LookUp(colProcessSteps, StepID = varThisStep.ID)
     },
     With(
     {
     nextstepnumber: thisstep.StepNumber + 1
     },
     With(
     {
     nextstepid: LookUp(colProcessSteps, StepNumber = nextstepnumber).StepID
     },
     If(
     thisstep.Complete,
     With({x: Patch(colProcessSteps, thisstep, {Complete: false})}, true),
     With({xx: Patch(colProcessSteps, thisstep, {Complete: true})}, true);
     Set(varThisStep, LookUp(BusinessProcessSteps, ID = nextstepid))
     )
     )
     )
    )

     

    Thanks Randy

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    This is an anomaly in the With statements that I have found when you try to use an If in the With (sounds like a bad song).

    Essentially in the If statement, all of the functions need to return the exact signatures.  In this case, Patch and Set (which returns nothing) will confuse everything and you'll get the error.

     

    I see that your original thread is locked and not viewable, so I don't know the context of what you were trying to solve - but I am guessing it was related to delegation.

     

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 337 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 250

#3
Mohsin Ali Profile Picture

Mohsin Ali 225

Last 30 days Overall leaderboard