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

How to disable choice in combo box after form is submitted

I am looking for a way to remove or disable a combo box choice after it is selected and user submit the form.

I have an app for student to vote  on his/her assigned projects.

What the app does?

Student has to vote for the assigned projects from the most interested to the least. 

Each student is assigned to 4 projects.

Once the student selects the assigned project name, selects his/her class, selects the interest scale and enters a brief comment then submits the form.

The data is then written to the SharePoint List.

What I am looking for?

Once the student submitted the form for each project choice, I need the submitted choice to be disabled.  He/she can only vote once for each project and not able to go back and edit once the form is submitted.

Once all 4 assigned projected is voted and submitted then the Project Name Combo box choice will also be disabled.

Question?

Is this even possible in power app?  I am willing to listen for alternative recommendations.

This is a screenshot of the editform app.

davidvo68_0-1648817955054.png

 

Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions
BrianS
Super User
Super User

It could be that you are actually saving the entire Record from the ComboBox. I imagine there is a way to get what you want from that record, but I would need to see the data. The easiest thing may be to set a variable to just the project name before you Submit the form. In the OnChange of the ComboBox use:

Set(var_Proj, Self.Selected.Value)

Then change your RemoveIf to:

RemoveIf(col_Projects,Value=var_Proj)

That should get you what you need

View solution in original post

8 REPLIES 8
BrianS
Super User
Super User

Will this all be filled out in 1 session? That would make things easier. 

You could use a Collection to hold the DropDown choices. Then as each project is submitted you would just remove that choice from the collection. Once your collection becomes empty (you can check with the IsEmpty() function) then you can use that to set your DropDown's Visible property.

If they can do this over more than one session, you will need to complicate things a little with the SaveData function for your Collection

davidvo68
Helper II
Helper II

Thank you for your quick reply Brian.

I never work with Collection so not sure how to pursue from your tip.

I will look on Microsoft Document and if I am able to solve this by using Collection then I will accept your reply as solution.

 

BrianS
Super User
Super User

Collections are just a way of saving tables or fields into the memory of the device for quick retrieval. You would create the collectio in the OnStart of the app. Something like:

ClearCollect(col_Projects,["Project1","Project2","Project3","Project4"])

Then your ComboBox would have col_Projects in the Items Property. Once someone filed out the form you would add some code after the Form was submitted:

RemoveIf(col_Projects,Value=Form.LastSubmit.ProjectName)

substituting the name of your Form and the field name

For the Visible Property of your ComboBox you would use:

!IsEmpty(col_Projects)

which make make it invisible when the last Project form is filled out.

Hope that gets you started

davidvo68
Helper II
Helper II

OnSelect of IconAccept1's Property I have the below code.

SubmitForm(EditForm1); RemoveIf(col_Projects,Value=EditForm1.LastSubmit.'Project Name')

However, it is giving an error. Here is the screenshot of it.

davidvo68_0-1648827613370.png

 

BrianS
Super User
Super User

It could be that you are actually saving the entire Record from the ComboBox. I imagine there is a way to get what you want from that record, but I would need to see the data. The easiest thing may be to set a variable to just the project name before you Submit the form. In the OnChange of the ComboBox use:

Set(var_Proj, Self.Selected.Value)

Then change your RemoveIf to:

RemoveIf(col_Projects,Value=var_Proj)

That should get you what you need

Thank you so much Brian.

It worked.

Hi Brian,

Since each student is assigned to the same 4 projects for them to vote on, I like to only remove the voted project choices per student after they voted.

Example:

Student A, Student B and Student C all have been assigned to the same Project A, B, C, and D.

Student A voted on his Projects A, B, C, D then he is done.  Next time he logs into the app, he should not see any choices appear in the Project combo box.

Meanwhile, Student B has not voted for his projects and he should see all 4 project choices on his Project combo box after he logs in.

How can I accomplish this?

BrianS
Super User
Super User

In that case I would add a Boolean field to the Student's record (StudentVote). Once the student submits a vote, change that value to true. Then you can set the DisplayMode of the project selector based on that new field:

If(StudentVote, DisplayMode.Disabled, DisplayMode.Edit)

 

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

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.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (2,487)