web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Flip checkbox in neste...
Power Apps
Answered

Flip checkbox in nested gallery

(0) ShareShare
ReportReport
Posted on by

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

 

Categories:
I have the same question (0)
  • v-xida-msft Profile Picture
    Microsoft Employee on at

    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,

  • werner1 Profile Picture
    on at

    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.

     

  • Verified answer
    v-xida-msft Profile Picture
    Microsoft Employee on at

    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,

     

  • werner1 Profile Picture
    on at

    @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

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 483

#2
WarrenBelz Profile Picture

WarrenBelz 399 Most Valuable Professional

#3
11manish Profile Picture

11manish 327

Last 30 days Overall leaderboard