cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Ashok2
Level: Powered On

Patching with condition in gallery

For each item in gallery i am having Checkbox3_1 ,on submit button i am submitting value to approved with action perform date all for check box who are checked

but now i have condition like if Status equal to "Draft" then Patch the status "approved" else if status equal to "approved" patch the status "completed" with new action date

ForAll(RenameColumns(Filter(SPLIST_1.AllItems,Checkbox3_1.Value),"ID","ID1"),Patch(SPLIST,LookUp(SPLIST,ID=ID1),{Status:{Value:"approved"},ActionDate:Today()}))

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: Patching with condition in gallery

@Ashok2 

Yes, we can continue to modify the code like this.

 

ForAll(
    RenameColumns(Filter(SPLIST_1.AllItems,Checkbox3_1.Value),"ID","ID1"),
    Patch(
        SPLIST,
        LookUp(SPLIST,ID=ID1),
        {Status:{Value:
            Switch(
                LookUp(SPLIST,ID=ID1).Status.Value,
                "draft", "approved",
                "approved", "completed"
            )
        },
        ActionDate: 
        Switch(
            LookUp(SPLIST,ID=ID1).Status.Value,
            "draft", Today(),
            "approved", LookUp(SPLIST,ID=ID1,ActionDate)
        ),
        ActionDateNew: 
        Switch(
            LookUp(SPLIST,ID=ID1).Status.Value,
            "draft", LookUp(SPLIST,ID=ID1,ActionDateNew),
            "approved", Today()
        )
        }
    )
)

 

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

View solution in original post

4 REPLIES 4
Super User
Super User

Re: Patching with condition in gallery

@Ashok2

You could use the SWITCH function to change the status based on its current value.

 

ForAll(
    RenameColumns(Filter(SPLIST_1.AllItems,Checkbox3_1.Value),"ID","ID1"),
    Patch(
        SPLIST,
        LookUp(SPLIST,ID=ID1),
        {Status:{Value:
            Switch(
                LookUp(SPLIST,ID=ID1).Status.Value,
                "draft", "approved",
                "approved", "completed"
            )
        },ActionDate:Today()}
    )
)

 

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

Ashok2
Level: Powered On

Re: Patching with condition in gallery

yes it working as expected but can we set different date for " draft" ,"approved"  ActionDate.Today();

"approved " ,"Completed"  ActionDateNew.Today(); 

 

ActionDate and ActionDateNew both are two different columns.

 

Highlighted
Super User
Super User

Re: Patching with condition in gallery

@Ashok2 

Yes, we can continue to modify the code like this.

 

ForAll(
    RenameColumns(Filter(SPLIST_1.AllItems,Checkbox3_1.Value),"ID","ID1"),
    Patch(
        SPLIST,
        LookUp(SPLIST,ID=ID1),
        {Status:{Value:
            Switch(
                LookUp(SPLIST,ID=ID1).Status.Value,
                "draft", "approved",
                "approved", "completed"
            )
        },
        ActionDate: 
        Switch(
            LookUp(SPLIST,ID=ID1).Status.Value,
            "draft", Today(),
            "approved", LookUp(SPLIST,ID=ID1,ActionDate)
        ),
        ActionDateNew: 
        Switch(
            LookUp(SPLIST,ID=ID1).Status.Value,
            "draft", LookUp(SPLIST,ID=ID1,ActionDateNew),
            "approved", Today()
        )
        }
    )
)

 

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

View solution in original post

Ashok2
Level: Powered On

Re: Patching with condition in gallery

Perfect Thank you 🙂

Helpful resources

Announcements
Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Join THE global Microsoft Power Platform event series

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (9,538)