cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mayarnaldo
Helper II
Helper II

If statement in Patch function

Hi,

 

I have a ForAll Patch and inside is an IF statement. This is a checkbox status. If the status is in "Created" and it is OnCheck then it should change it's status in "Ready". But my IF statement is not working. 

 

ForAll(
    SelectedItemsColl As sic,
    Patch(
        'Inspection Request Detail List',
        LookUp(
            SelectedItemsColl,
            ID = sic.ID
        ),
        If(Status.Value in "Created", {Status.Value: "Ready"},
        Status.Value in "Ready", {Status.Value: "In-Room"},
        Status.Value in "In-Room", {Status.Value: "Presented"},
        Status.Value in "Presented",{Status: Inactive, Status.Value: "Closed"}
        )
    
        )
    );

 

Can anyone help me to spot where I am doing it wrong? 🙂

 

Any helps really appreciated! Thank you.

 

Regards,

May

4 REPLIES 4
mdevaney
Super User
Super User

@mayarnaldo 

Do you have four checkboxes on the screen?  If you want to take an action when a checkbox is 'checked' then you should refer to that specific checkbox and determine if its true.  If yes, then change the status.

Also, you may wish to reverse the order of your code to 

  • Presented
  • InRoom
  • Ready
  • Created

 

ForAll(
    SelectedItemsColl As sic,
    Patch(
        'Inspection Request Detail List',
        LookUp(
            SelectedItemsColl,
            ID = sic.ID
        ),
        If(checkbox_Created.Value=true, {Status.Value: "Ready"},
        checkbox_Ready.Value=true, {Status.Value: "In-Room"},
        checkbox_InRoom.Value=true, {Status.Value: "Presented"},
        checkbox_Presented.Value=true,{Status: Inactive, Status.Value: "Closed"}
        )
    
        )
    );

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

 

 

 

Hi @mdevaney ,

 

Thank you for your reply.

 

Yes, I have a checkbox and an arrow to help move:

 

kanban_powerapps.png

 

But still it give me error 😞

 

Checkbox_complain.png

 

Regards,

May

 

@mayarnaldo 
I don't understand where the checkboxes for status are.  Can you please circle them on the screen?

RandyHayes
Super User
Super User

@mdevaney  Take a look at this post.  I believe it will shed some light on the problem that @mayarnaldo is having.

 

@mayarnaldo you might want to take a look at my response there as it will simplify what you are trying to do tremendously. 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
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.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (2,144)