cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
beniwal
Level: Powered On

submit form in a forall loop

Hi,

 

I have this requirement to send email to multiple recipients with a Note.

 

And this is a many to many type of relationship, so I need to save the note for all the recipients in my sql server.

 

I am thinking if we can run a loop on the list of recipients and  edit the  recipient field and save multiple forms in the loop. But inside forall i am not able to do it.

 

Formula:

ForAll(Gallery.AllItems.id ,If(true,UpdateContext({SelectedID: id }) , SubmitForm(Form9_3)))

 

I am using "SelectedID" as the default value of "id" field in my form.

 

Please guide me what to do ? If you have any better idea please suggest 🙂

Thanks,

Mohit 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: submit form in a forall loop

Hi @beniwal ,

Could you please share a bit more about your scenario?

Do you want to submit your form data for each recipient within your Gallery?

Further, could you please share a screenshot about your app's configuration?

 

Based on the needs that you mentioned, I think the SubmitForm() function could not achieve your needs. As an alternative solution, I think the combination of ForAll function and Patch function could achieve your needs.

 

I have made a test on my side, please consider take a try with the following workaround:

Set the OnSelect property of the "Submit" button to following:

ForAll(
           RenameColumns(Gallery.AllItems, "id", "id1"),
           Patch(
                     'YourDataSource',               /* <-- The 'YourDataSource' represents the data source your Form9_3 connects to */
                     Defaults('YourDataSource'),
                     {
                       id: id1,
                       Coumn2: Column2FromYourGallery,
                       Column3: Column3FromYourGallery,
                       ...
                     }
           )
)

Note: The Column2FromYourGallery, Column3FromYourGallery, ... represents the column values from your Gallery. Within the '{}' part of the Patch function, you could reference column values from your Gallery. The id, Column2, Column3, ... represents the columns in your data source (your Form9_3 connects to).

 

More details about the ForAll function, Patch function and RenameColumns function, please check the following article:

ForAll function

Patch function

RenameColumns function

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
K-A-R-L
Level 10

Re: submit form in a forall loop

Hi @beniwal ,

I'm pretty sure you should be able to run a function inside a ForAll() by using the semi-colon character (;) to seperate each function.


Can you please run this code and check if it works for you.

ClearCollect(
    NewCollection1,
    {Wheels: 2,Type: "Bicyle"},
    {Wheels: 3,Type: "Tricycle"},
    {Wheels: 4,Type: "Quadricycle"}
);
ForAll(
    NewCollection1,
    If(Wheels = 2,Collect(TwoWheelCollection, {Type: Type}));
    If(Wheels = 4,Collect(FourWheelCollection, {Type: Type});SubmitForm(Form1))
)

In your case you need to collect the Items on your gallery.

If(Collection, //Name of Collected Items on Gallery
                   !IsBlank(Collection) //Use your formula
                   UpdateContext({SelectedID: id }); //Updates the SelectedID Varaible on that Screen
                   SubmitForm(Form9_3)) //Submits the Form
)

----------------------------------------------------------------------------
Thanks,
K-A-R-L


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If you thought this post was helpful, please give it a Thumbs Up.

Community Support Team
Community Support Team

Re: submit form in a forall loop

Hi @beniwal ,

Could you please share a bit more about your scenario?

Do you want to submit your form data for each recipient within your Gallery?

Further, could you please share a screenshot about your app's configuration?

 

Based on the needs that you mentioned, I think the SubmitForm() function could not achieve your needs. As an alternative solution, I think the combination of ForAll function and Patch function could achieve your needs.

 

I have made a test on my side, please consider take a try with the following workaround:

Set the OnSelect property of the "Submit" button to following:

ForAll(
           RenameColumns(Gallery.AllItems, "id", "id1"),
           Patch(
                     'YourDataSource',               /* <-- The 'YourDataSource' represents the data source your Form9_3 connects to */
                     Defaults('YourDataSource'),
                     {
                       id: id1,
                       Coumn2: Column2FromYourGallery,
                       Column3: Column3FromYourGallery,
                       ...
                     }
           )
)

Note: The Column2FromYourGallery, Column3FromYourGallery, ... represents the column values from your Gallery. Within the '{}' part of the Patch function, you could reference column values from your Gallery. The id, Column2, Column3, ... represents the columns in your data source (your Form9_3 connects to).

 

More details about the ForAll function, Patch function and RenameColumns function, please check the following article:

ForAll function

Patch function

RenameColumns function

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

beniwal
Level: Powered On

Re: submit form in a forall loop

hi @v-xida-msft 

 

Thanks it worked 🙂

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

New Badges

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors
Users online (4,518)