cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
newb
Frequent Visitor

ForAll Collection Patch

Hi All,

In my app, I have a questionnaire built in a gallery.
My goal is upon successfully answering all the required questions, patching those questions that have been answered.
As I have a few different types of questions in my gallery, such as date or text, I am saving the answers in a hidden Answers_lbl of each gallery Item, then for all the gallery items where Answers_lbl is not Blank, I am creating a collection. In a next screen the user needs to confirm their answers and I want to patch the items of the collection. I am using a dataverse as my data source to save all of my answers.
My current formula for Patching the collection items is the following:

ForAll(
    ColAnsweredQuestions,
Patch(
       'Questionnaire answers',
       Defaults('Questionnaire answers'),
       {
        Answer: CAnswer
    }
    )
);     

 
I get an error that my ForAll and Patch functions have some invalid arguments. Any ideas on where am I making a mistake?

1 ACCEPTED SOLUTION

Accepted Solutions
BCLS776
Super User
Super User

What is CAnswer? If it is a field in the ColAnsweredQuestions collection, you'll need to modify your code to this:

 

ForAll(
    ColAnsweredQuestions As aQuestion,
    Patch(
        'Questionnaire answers',
        Defaults('Questionnaire answers'),
        {
            Answer: aQuestion.CAnswer
        }
    )
);     

Hope that helps,

Bryan

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

View solution in original post

2 REPLIES 2
BCLS776
Super User
Super User

What is CAnswer? If it is a field in the ColAnsweredQuestions collection, you'll need to modify your code to this:

 

ForAll(
    ColAnsweredQuestions As aQuestion,
    Patch(
        'Questionnaire answers',
        Defaults('Questionnaire answers'),
        {
            Answer: aQuestion.CAnswer
        }
    )
);     

Hope that helps,

Bryan

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.
surajkv
Helper I
Helper I

Hi @newb Please can try below formula


ForAll( ColAnsweredQuestions,
Patch('Questionnaire answers',
{
Answer: CAnswer
}))

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (1,659)