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 / Collect Gallery items ...
Power Apps
Answered

Collect Gallery items and then patch to Sharepoint

(0) ShareShare
ReportReport
Posted on by 103

I have a scenario in which I have a gallery made up of questions based on the country someone picked ( each country may have a different combination of questions and every time they choose a country or use the onchange property of the country selector dropdown, I collect the questions for that country and their questions data type (Date,text input, choice, yes/no, etc).) into a questions_collection. Now then I use this questions collection as the data source for the project question list for the user to fill out and provide their answers. In the gallery I have one control for each of the data types, one text input control for multi-line answers, one date_input control for date answers, one choice control for choice answers and a radio button control for yes/no answers. Now what I need to do is somehow patch these answers back to a master answer list in Sharepoint and the way I'm thinking is to use a forall(collect function to collect all the answers in the gallery and then patch that collection to the data source? I think thats the way to go about it, but I have run into some obstacles so far and was looking to see if anyone had any suggestions on making this easier? The SharePoint Answers list currently has every column for each of the questions and upon patch even if the question was not in that country set, I'm assuming I would need to give it a blank value? Any advice on how to go about this would be much appreciated

Here is my current code for the collection: 

 

Clear(col_answers);
ForAll('Project Type Questions'.AllItems,Collect(col_answers,{Question:Question_lb.Text},{Dates:Date_Input.Value},{Question_Text: Text_Input.Text},{Yes_No:Radio1.Selected.Value},{Choice:Choice_Input.SelectedItems}))

 

But I am getting a weird result:

Bhanes22_0-1661707874501.png
I'm not sure why its skipping so many lines in between one another because the gallery looks like this:

Bhanes22_0-1661708357459.png

 

 

Categories:
I have the same question (0)
  • AhmedSalih Profile Picture
    6,680 Moderator on at

    Hello, @Bhanes22 ,

    EDITED my Reply:

    I thought it is the syntax what causing the problem. @Drrickryp post is addressing the issue.

     

    you have to use ThisRecord in your Collect function:

     

    Clear(col_answers);
    ForAll('Project Type Questions'.AllItems,Collect(col_answers,{Question:ThisRecord.FieldOfQuestion},{Dates:ThisRecord.DateInputField},{Question_Text: ThisRecord.QuestionField},{Yes_No:ThisRecordYes/NOField},{Choice:ThisRecord.ChoiceField}))

     

     

     

    If my reply helped you, please give a 👍, & if it solved your issue, please 👍 & Accept it as the Solution to help other community members find it more.

    I am primarily available on weekdays from 6-10 PM CT and 5-10 PM CT on weekends.

    Visit my Blog: www.powerplatformplace.com

     

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @Bhanes22 

    A flexible database design would look something like this and consists of 5 separate lists.

     

     - user
     - id (PK)
     - last_name
     - first_name
     - email
     - gender
    
    
     - quiz
     - id (PK)
     - title
    
    
     - quiz_question
     - id (PK)
     - quiz_id (FK)
     - text
    
     - quiz_question_option
     - id (PK)
     - quiz_question_id (FK)
     - text
     - is_correct
    
     - quiz_user_answer
     - id (PK)
     - quiz_question_id (FK)
     - quiz_question_option_id // this is the answer.

    ref; https://stackoverflow.com/questions/7102521/database-design-for-developing-quiz-web-application-using-php-and-mysql 

     

     

  • Bhanes22 Profile Picture
    103 on at

    It is still showing up weird in the collection:

    Bhanes22_0-1661712441282.png
    Heres my code: 

    Clear(col_answers);
    ForAll('Project Type Questions'.AllItems,Collect(col_answers,{Question:ThisRecord.Question_lb.Text},{Dates:ThisRecord.Date_Input.Value},{Question_Text: ThisRecord.Text_Input.Text},{Yes_No:ThisRecord.Radio1.Selected},{Choice:ThisRecord.Choice_Input.SelectedItems}))

     

  • Bhanes22 Profile Picture
    103 on at

    Figured out what I was doing wrong, need the brackets around everything, not brackets for each field. TY!!!<3

  • Verified answer
    AhmedSalih Profile Picture
    6,680 Moderator on at

    @Bhanes22 , you right, I didn't pay attention to those curly brackets. 

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 329 Most Valuable Professional

#2
11manish Profile Picture

11manish 209 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 179

Last 30 days Overall leaderboard