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 Apps
Answered

Patch Help!

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi all,

 

I'm pretty new to Powerapps and was hoping someone can help me.  I've got a connection to 2 SQL tables - one full of questions and the other ready for answers.

 

My app collects the data from the question table and then loops through them, asking a multi choice question for each, dynamically building the Q&A's based on the data.

 

As the user answers a question I'm Collecting the data on push of the submit...some of the data is coming from the existing questionnbank collection and some from the text or radio button...currentRow is my loop control.

 

Collect(myResults,{child_org_id:12345,category_id:Last(FirstN(questionbank,currentRow)).category_id,question_id:Last(FirstN(questionbank,currentRow)).question_id,index_ref:Last(FirstN(questionbank,currentRow)).indexIndicator,question_type:Last(FirstN(questionbank,currentRow)).question_type,maximum_score:Last(FirstN(questionbank,currentRow)).maximum_score,numeric_answer:Radio1.Selected.myValue,verbatim_answer:TextInput1.Text,uid:Text(usersap),completion_ref:completionRef,createddatetime:Now(),rebased:0});

 

Which works fine.

 

Now, when I reach the last question I want to patch this data to the t_results datasource -  I've tried patch('DS',Default('DS)',myResults) but to no avail...

 

I know I could patch each record in turn, but I need the user to complete all questions, so a final submission is preferrable.

 

I've read some posts on batch patching, but I'm a bit lost...Can anybody suggest a solution?

 

Thanks

Categories:
  • Verified answer
    CarlosFigueira Profile Picture
    Microsoft Employee on at

    Patch can only work for a single record, so you won't be able to use it directly to add all the answers to the table. There are a couple of options you can use, however:

    • Use Collect, where you can pass a collection, and all items of the collection are added to the data source
    • Use the Patch operation inside a ForAll, in which you can use Patch for the individual items of the collection

    An example of the ForAll would be similar to the expression below:

    ForAll(
     myResults,
     Patch(
     '[dbo].[forumpost_116637]',
     Defaults('[dbo].[forumpost_116637]'),
     {
     category_id: category_id,
     child_org_id: child_org_id,
     index_ref: index_ref,
     question_id: question_id,
     ...
     numeric_answer: numeric_answer,
     verbatim_answer: verbatim_answer
     }))

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 397 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 354

#3
WarrenBelz Profile Picture

WarrenBelz 232 Most Valuable Professional

Last 30 days Overall leaderboard