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
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Top Solution Authors
Top Kudoed Authors
Users online (1,521)