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

Flip checkbox in nested gallery

I'm working on this app that shows a dynamic questionnaire with normal text or multiple choice answers. Questions and possible multi-choice answers are stored on SP lists, and I also want to save users "responses". The questions are the first level gallery and the multiple choice answers are the 2nd level gallery. The text input and the multiple choice gallery will be on top of each other and visibility controled by the "type" of question (column of the questions list, can be text or multiple).

My test screen is mostly working, but my problem is that when I select one choice I want to uncheck the other choices (only one possible answer can be checked) if they are on, but only for that question.

I'm setting variables with the questions and the answer with the oncheck and uncheck and using these on the default property but what to do when it's not the current question?

 

default=If(IsBlank(ThisItem.response),If(ThisItem.question_ID=currentSelectedQuestion,If(ThisItem.Multiple_option=currentSelectedAnswer, true , false ), ?????? ),If(ThisItem.response=ThisItem.Multiple_option, true , false ))

The Gallery_Question is populated with:

AddColumns(mqc_questions, "response", LookUp(test_Collection, And(client_no = Label_Client_No.Text, question = Title)).response) 

and the Gallery_Answers: AddColumns(Filter(mqc_answers,question_ID=ThisItem.Title),"response",LookUp(test_Collection,And(client_no=Label_Client_No.Text,question=question_ID)).response)

image.png

I did tried a version where I patched the responses at the Oncheck and Uncheck events but that seems to loose the current position as the gallery is refreshed, and the user has to click twice to enter the next answer.
All advice is appreciated,

Thanks

Werner

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Flip checkbox in nested gallery

Hi @werner1 ,

I agree with you, you could consider save all changes you made within your nested Gallery into your test_collection via press the "Save" button at the bottom.

 

In addition, you could also consider save the current selected question item from your Question Gallery into a variable, then set the Default property of the Question Gallery to this variable.

 

I have made a test on my side, please consider take a try with the following workaround:

Add the following formula within the OnCheck property of the Checkbox box in your nested Gallery:

 

Set(CurrentSelectedQuestion, Gallery_Question.Selected);        /* <-- Add this formula */
Patch(                     /* <-- Save the checkbox value into the response column in your test_Collection */
        test_Collection,
        LookUp(test_Collection, client_no = Label_Client_No.Text && question = ThisItem.question_ID)
        {
           response: Gallery_Answers.Selected.Checkbox1.Text              /* <-- Gallery_Answers represents the nested Gallery */
        }  
)

then set the Default property of the Question Gallery to following:

CurrentSelectedQuestion

Please take a try with above solution and your thought, check if the issue is solved. If this issue is solved, please consider go ahead to click "Accept as Solution" to identify this thread has been solved.

 

Best regards,

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Community Support Team
Community Support Team

Re: Flip checkbox in nested gallery

Hi @werner1 ,

Could you please share a bit more about the "response" column that you mentioned? Do you use it to store user's response?

Could you please share a bit more about the formula you typed within the Text property of the Checkbox within your nested Gallery?

 

Based on the needs that you mentioned, I suppose that the "response" column is a column in your test_Collection, which is used to store the user's response, is it true?

 

I have made a test on my side, please take a try with the following workaround:

Within your nested Gallery (Gallery_Answers gallery), set the OnCheck property of the Checkbox (Checkbox1) to following:

Patch(                     /* <-- Save the checkbox value into the response column in your test_Collection */
        test_Collection,
LookUp(test_Collection, client_no = Label_Client_No.Text && question = ThisItem.question_ID)
{
response: Gallery_Answers.Selected.Checkbox1.Text /* <-- Gallery_Answers represents the nested Gallery */
} )

or

Patch(
        test_Collection,
LookUp(test_Collection, client_no = Label_Client_No.Text && question = ThisItem.question_ID)
{
response: Checkbox1.Text /* <-- Gallery_Answers represents the nested Gallery */
} )

set the OnUncheck property of the Checkbox (Checkbox1) to following:

Patch(                     /* <-- Save the checkbox value into the response column in your test_Collection */
        test_Collection,
LookUp(test_Collection, client_no = Label_Client_No.Text && question = ThisItem.question_ID)
{
response: Blank()
} )

 

Set the Default property of the Checkbox (Checkbox1) within your nested Gallery to following:

If(
ThisItem.response = ThisItem.Multiple_option,
true,
false
)

Note: I assume that the Text property of the Checkbox in your nested Gallery has been set to following:

ThisItem.Multiple_option

Please consider take a try with above solution, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
werner1
Level: Powered On

Re: Flip checkbox in nested gallery

Hi @v-xida-msft 
Correct: the "Response"column will store the text of the multiple choice (yes, no, whole season ...) for a multiple choice question or the text from text input control for the other type of question.
You are correct on your assumptions, and your suggestion on patch on OnCheck and OnUncheck is exactly what I tried on a version before. What I experieced then is after entering an answer and clicking on the next one would "loose" the current position, and I would need to click on the input control again to enter something. I assume that's because the gallery was refreshed after the patch command and current position went back to the first item of the gallery.
Because of this unvanted behaviour, I've been trying to have all the saving to the test_collection with the users responses done at the end with a Save button.

Hope that cleared a bit more.

 

Community Support Team
Community Support Team

Re: Flip checkbox in nested gallery

Hi @werner1 ,

I agree with you, you could consider save all changes you made within your nested Gallery into your test_collection via press the "Save" button at the bottom.

 

In addition, you could also consider save the current selected question item from your Question Gallery into a variable, then set the Default property of the Question Gallery to this variable.

 

I have made a test on my side, please consider take a try with the following workaround:

Add the following formula within the OnCheck property of the Checkbox box in your nested Gallery:

 

Set(CurrentSelectedQuestion, Gallery_Question.Selected);        /* <-- Add this formula */
Patch(                     /* <-- Save the checkbox value into the response column in your test_Collection */
        test_Collection,
        LookUp(test_Collection, client_no = Label_Client_No.Text && question = ThisItem.question_ID)
        {
           response: Gallery_Answers.Selected.Checkbox1.Text              /* <-- Gallery_Answers represents the nested Gallery */
        }  
)

then set the Default property of the Question Gallery to following:

CurrentSelectedQuestion

Please take a try with above solution and your thought, check if the issue is solved. If this issue is solved, please consider go ahead to click "Accept as Solution" to identify this thread has been solved.

 

Best regards,

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

werner1
Level: Powered On

Re: Flip checkbox in nested gallery

@v-xida-msft 

Hi Kris,

After a bit of thinking, I can see some way out of my problem.

I appreciate you help, and learned something new with setting the default property of the gallery.

Thanks

Werner

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

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

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

Top Kudoed Authors
Users Online
Currently online: 95 members 3,322 guests
Please welcome our newest community members: