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

Update context for one gallery item only?

Hello!  

I have created an app where teachers can submit student performance data per class period.  Since different teachers have different students depending on the day of the week and class period I am displaying the information as a gallery with controls within the gallery (see screenshot below)screenshot1.PNG

Teachers are having difficulty remembering if they submitted the student report and have been doing it multiple times so I want to disable the submit button after they have pressed it once.   I have tried using UpdateContext but it disables the button for all gallery items instead of just one.  Is there a way to just disable the button for one gallery item but not for all of them?  Thank you for your help!

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Update context for one gallery item only?

If you're putting that on just that button control, then it would have no impact on the other buttons.

 

BUT - I believe I may have misunderstood your original issue.  I had thought you were working with an EditForm, but in fact (if I'm now correct), you are doing this all in a Gallery.  So basically each student is listed with each one having this exact "form" that you showed in your photo.

 

If that is all the case, then you will need to do a little extra thinking on the logic.  Yes, you are correct that changing the displaymode on one will do them all (again, I had assumed you were saying that the other items like the "Absent" button were getting disabled).  

So, one option you have is to keep track of the state in the underlying collection.

 

For your collection (and I assume you are building your collection and assigning it to the gallery), you can do something like this:

   AddColumns(yourCollection, "Submitted", false)

 

Then, when the user hits the submit button, put this logic in the OnSelect of the submit button:

   Patch(yourCollection, ThisItem, {Submitted:true})

 

Then for your DisplayMode on the button, put this logic:

   If(ThisItem.Submitted, Disabled, Edit)

 

Keep in mind (since I don't have any details on your datasource or how you are updating records when they hit submit), this adds a column to the collection.  If you are trying to patch the record directly from the Gallery, you will get an error because the "Submitted" column does not exist in your datasource.  In that case, be sure to do a RemoveColumns on the item before submitting.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

6 REPLIES 6
Highlighted
Super User
Super User

Re: Update context for one gallery item only?

Change the DisplayMode property of the Submit Button to Disabled based on your condition.

 

DisplayMode -  If(whateverYourConditionToTestDisabled, Edit)

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
jdelorenze
Level: Powered On

Re: Update context for one gallery item only?

Thank you, but this still seems to disable the button for all active gallery records instead of just one.  Am I just not testing the right condition?

Super User
Super User

Re: Update context for one gallery item only?

Can you provide the formula for the button, for the displaymode property? Let's see what you're working with.
_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
jdelorenze
Level: Powered On

Re: Update context for one gallery item only?

All I really have is what you said --- If(???, Disabled, Edit) --- I don't know what condition to test for as I just want the button to disable after it has been pressed.  I've tried using the button to trigger a timer then testing like this If(Timer1>0, Disabled, Edit)... but that still disables the button for every gallery record, not just one.

Super User
Super User

Re: Update context for one gallery item only?

If you're putting that on just that button control, then it would have no impact on the other buttons.

 

BUT - I believe I may have misunderstood your original issue.  I had thought you were working with an EditForm, but in fact (if I'm now correct), you are doing this all in a Gallery.  So basically each student is listed with each one having this exact "form" that you showed in your photo.

 

If that is all the case, then you will need to do a little extra thinking on the logic.  Yes, you are correct that changing the displaymode on one will do them all (again, I had assumed you were saying that the other items like the "Absent" button were getting disabled).  

So, one option you have is to keep track of the state in the underlying collection.

 

For your collection (and I assume you are building your collection and assigning it to the gallery), you can do something like this:

   AddColumns(yourCollection, "Submitted", false)

 

Then, when the user hits the submit button, put this logic in the OnSelect of the submit button:

   Patch(yourCollection, ThisItem, {Submitted:true})

 

Then for your DisplayMode on the button, put this logic:

   If(ThisItem.Submitted, Disabled, Edit)

 

Keep in mind (since I don't have any details on your datasource or how you are updating records when they hit submit), this adds a column to the collection.  If you are trying to patch the record directly from the Gallery, you will get an error because the "Submitted" column does not exist in your datasource.  In that case, be sure to do a RemoveColumns on the item before submitting.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

jdelorenze
Level: Powered On

Re: Update context for one gallery item only?

Thanks a ton for all of your help with this.  Your solution worked!  I really appreciate it.

Jason

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

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

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 179 members 4,177 guests
Please welcome our newest community members: