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 / Dynamic galery patch
Power Apps
Answered

Dynamic galery patch

(0) ShareShare
ReportReport
Posted on by 28

Hi,

Can I please get help with my app. Not an experienced user and just cannot figure out how to do this.

I have a gallery (gallery1) where user is answering a series of questions, then this gallery is getting patched up to the sharepoint list. No issues there.

I would like to introduce a dynamic experience, where questions are split into different categories (another gallery (gallery2), and then main galley is fileted depending on witch tab is selected). Gallery 2 is based on the table and new categories can be added, hence i do not wish to create a manual table in the app, hence dynamic.

What i'm struggling with is: when user answers first set of questions and then selects a next category, all answers from the first category disappear...how do i make the answers to remain in the gallery and only disappear when i patch all the answers from all categories to the sharepoint? Thank you

I've tried to create a collection when the first tab is selected, but the collection does not register the answers (shows as 'Control undefined' and then when i tried to patch the answers to the collection the formular has errors but i cannot understand what error is, even when patching only one item...help please

Also, there could be situations where not all questions are answered. I've defaulted column 4 to n/a so even when some questions are missed, the record is still created (so it can be edited at a later time), n/a is across all categories. So I need to be able to patch up all sets of questions at the end.

 

Gallery1: Filter(colFormTemplate, Category=varCurrentTab)

Gallery2:  colMenuTabs. Category selection is: Set(varCurrentTab,ThisItem.Category)

 

 

 

Screenshot 2023-11-06 114339.png
Categories:
I have the same question (0)
  • Verified answer
    M_Ali_SZ365 Profile Picture
    1,110 on at

    Hi @Ali79 

    Try This

    When the app starts, clear out any old data and set up a fresh, empty collection:

    ClearCollect(UserAnswers, [])

    Before you change categories, make sure you save the current answers. Use a button or some other trigger to run this:

    ForAll(Gallery1.AllItems, Collect(UserAnswers, {Question: ThisItem.Question, Answer: ThisItem.YourTextInput.Text, Category: varCurrentTab}))

    So, the Items property for Gallery1 will look something like this:

    Filter(colFormTemplate, Category = varCurrentTab)

     

    And set the Default property of each answer control in Gallery1 to:

    LookUp(UserAnswers, Question = ThisItem.Question && Category = varCurrentTab, Answer)

    When the user has finished answering all questions across categories, you'll send all the collected data to SharePoint. You could have a "Submit" button do this with something like:

    ForAll(UserAnswers, Patch(SharePointList, Defaults(SharePointList), {Title: Answer, Category: Category}))

    Again, make sure Title and Category are named exactly like your SharePoint columns.

    If a user doesn't answer a question, you can set it to "N/A" as they go or when you do the final patch to SharePoint. If you want to do this as you go, adjust your collect formula like this:

    Collect(UserAnswers, {Question: ThisItem.Question, Answer: If(ThisItem.YourTextInput.Text = "", "N/A", ThisItem.YourTextInput.Text), Category: varCurrentTab})

    Please accept this solution if it resolves the issue.
    Best regards,
    Muhammad Ali

  • Ali79 Profile Picture
    28 on at
    Muhammad, Thank you. I'll try your suggestion.
  • Ali79 Profile Picture
    28 on at

    Thank you so very much! worked like a magic!

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 358 Most Valuable Professional

#2
11manish Profile Picture

11manish 214 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 185

Last 30 days Overall leaderboard