cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
kcgov
Frequent Visitor

Click button and update/change dropdown value in gallery

 

Hi everyone,

 

I have a screen for managers with a gallery, a display form, and edit form. The gallery shows the status of purchases submitted that default to Open from an option set (Open, Pending, Approved, Declined). The display form displays all the purchase information from a gallery record for the manager to review. The edit form currently displays the status as a dropdown. I would like to:

1. Add two buttons (Approve and Decline) to the edit form. OnSelect I would like Approve to update the dropdown DDStatus to Pending and submit an update to the record with a pop-up or label verifying the change. Clicking Decline should set the dropdown to Declined and update the record. 

*Note: I can get the buttons to change a dropdown's values outside of a gallery using UpdateContext({Status: "Pending"}) but cannot get it to work inside of a gallery and can't figure out why yet.

 

2. The second thing I would like to do is filter the gallery based on status based on the buttons clicked. I have it partially working but the All button shows all status records (Open, Pending, Approved, and Declined) instead of just Approved and Declined records. 

 

I have the following:

All button: Set(ArchiveStatus, "All")

Approved button: Set(ArchiveStatus, "Approved")

Declined button: Set(ArchiveStatus, "Declined")

 

Gallery
Filter(
PURCHASE,
If(
ArchiveStatus = "All" || IsBlank(ArchiveStatus),
true,
ArchiveStatus = "Approved",
'PURCHASE Status' = [@'PURCHASE Status'].Approved,
ArchiveStatus = "Declined",
'PURCHASE Status' = [@'PURCHASE Status'].Declined
)
)

 

canvasapp.png

 

I'd appreciate any help understanding what I'm doing wrong. Thanks!

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hey brother,

My bad for not mentioning this. Make sure the argument you are using is a unique identifier. That way, it would try to find that record in the entity and update it's Purchase Status.

//Idk your unique identifier for Purchase but it should be ID or something like PURCHASE ID
UpdateIf(PURCHASES, 'ID' = ThisItem.'ID', { 
    'PURCHASE Status': [@'PURCHASE Status'].'Pending'}
)

 

View solution in original post

4 REPLIES 4
ProjectVelox
Advocate III
Advocate III

Heyya brother!

I'd like to know what entity you are using, but this should work for you:

Place this code on the OnSelect property of your button within the Gallery.

UpdateIf(colOrders, Order = ThisItem.Order, { 
     'Status': [@'Status'].'Pending'
})


Just change the data source and the argument


Hi @ProjectVelox!

 

The data source is PURCHASES and the dropdown option set is PURCHASE Status.

 

i tried this but it doesn't seem to work 
UpdateIf(PURCHASES, 'PURCHASE Status' = ThisItem.'PURCHASE Status',
{ 'PURCHASE Status': [@'PURCHASE Status'].'Pending'})

 

ThisItem gave an error but using ThisRecord did not. It still didn't seem to work even though the it looked like something was happening.

Hey brother,

My bad for not mentioning this. Make sure the argument you are using is a unique identifier. That way, it would try to find that record in the entity and update it's Purchase Status.

//Idk your unique identifier for Purchase but it should be ID or something like PURCHASE ID
UpdateIf(PURCHASES, 'ID' = ThisItem.'ID', { 
    'PURCHASE Status': [@'PURCHASE Status'].'Pending'}
)

 

View solution in original post

That makes sense, thank you!

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (3,721)