cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Nagaviswanath
Kudo Commander
Kudo Commander

How to bulk update multiple rows with 7 columns each using ForAll and Patch functions

Hello,

 

I am writing this as i cannot see any solution for this in the forum. I am trying to bulk update 5 rows each contains 7 columns with different values using ForAll and patch functions. However, it is getting updated with same value for all 5 rows.

 

My formula for Submit button:

ForAll(Timesheet,(Patch(TimeSheet_Week1,{Day: Value(TextBox8.Text),Worked: Value(TextInput1.Text),Vacation: Value(TextInput2.Text),Sick:Value(TextInput3.Text),Overtime: Value(TextInput4.Text),Client: TextInput5.Text,Location: TextInput6.Text},{Day: Value(TextBox10.Text),Worked:Value (TextInput7.Text),Vacation: Value(TextInput8.Text), Sick:Value(TextInput9.Text), Overtime:Value(TextInput10.Text), Client:TextInput11.Text, Location:TextInput12.Text},{Day: Value(TextBox16.Text),Worked:Value (TextInput13.Text),Vacation: Value(TextInput14.Text), Sick:Value(TextInput15.Text), Overtime:Value(TextInput16.Text), Client:TextInput17.Text, Location:TextInput18.Text},{Day: Value(TextBox17.Text),Worked:Value (TextInput19.Text),Vacation: Value(TextInput23.Text), Sick:Value(TextInput24.Text), Overtime:Value(TextInput25.Text), Client:TextInput21.Text, Location:TextInput22.Text},{Day: Value(TextBox18.Text),Worked:Value (TextInput31.Text),Vacation: Value(TextInput30.Text), Sick:Value(TextInput29.Text), Overtime:Value(TextInput28.Text), Client:TextInput26.Text, Location:TextInput27.Text}))

 

I have created TimeSheet collection which will be created by clicking on Save button.

 

UI of the app:

Patch_ForAll.png

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hello,

 

I am not using gallery option as it wont give much room for the user to see all details for the week at a time. And i think i have find out the solution for my problem. I have created code for SAVE button to get collection populated and used ForAll funtion to store the data from collection to the CDS.

 

Formula for Save button:

ClearCollect(TimeSheet,
{Day: Value(TextBox8.Text),Worked: Value(TextInput1.Text),Vacation: Value(TextInput2.Text),Sick:Value(TextInput3.Text),Overtime: Value(TextInput4.Text),
Client: TextInput5.Text,Location: TextInput6.Text},
{Day: Value(TextBox10.Text),Worked:Value (TextInput7.Text),Vacation: Value(TextInput8.Text), Sick:Value(TextInput9.Text), Overtime:Value(TextInput10.Text),
Client:TextInput11.Text, Location:TextInput12.Text},
{Day: Value(TextBox16.Text),Worked:Value (TextInput13.Text),Vacation: Value(TextInput14.Text), Sick:Value(TextInput15.Text), Overtime:Value(TextInput16.Text),
Client:TextInput17.Text, Location:TextInput18.Text},
{Day: Value(TextBox17.Text),Worked:Value (TextInput19.Text),Vacation: Value(TextInput23.Text), Sick:Value(TextInput24.Text), Overtime:Value(TextInput25.Text),
Client:TextInput21.Text, Location:TextInput22.Text},
{Day: Value(TextBox18.Text),Worked:Value (TextInput31.Text),Vacation: Value(TextInput30.Text), Sick:Value(TextInput29.Text), Overtime:Value(TextInput28.Text),
Client:TextInput26.Text, Location:TextInput27.Text})

 

Formula for Submit button:
ForAll(TimeSheet,(Patch(TimeSheet_Week1,
{Day:Day,Worked: Worked,Vacation: Vacation,Sick:Sick,Overtime: Overtime,
Client: Client,Location: Location})))

View solution in original post

2 REPLIES 2
Meneghino
Community Champion
Community Champion

Hi @Nagaviswanath

 

I think a simpler approach would be to use a gallery to display your time sheet text input boxes and use the day value as an index to write back to the data source with the date.

Also, it seems laborious to create a new data source for each week of reporting, or at least that is what it seems like from your code.

 

If you wish to explore this, please let me know.

Hello,

 

I am not using gallery option as it wont give much room for the user to see all details for the week at a time. And i think i have find out the solution for my problem. I have created code for SAVE button to get collection populated and used ForAll funtion to store the data from collection to the CDS.

 

Formula for Save button:

ClearCollect(TimeSheet,
{Day: Value(TextBox8.Text),Worked: Value(TextInput1.Text),Vacation: Value(TextInput2.Text),Sick:Value(TextInput3.Text),Overtime: Value(TextInput4.Text),
Client: TextInput5.Text,Location: TextInput6.Text},
{Day: Value(TextBox10.Text),Worked:Value (TextInput7.Text),Vacation: Value(TextInput8.Text), Sick:Value(TextInput9.Text), Overtime:Value(TextInput10.Text),
Client:TextInput11.Text, Location:TextInput12.Text},
{Day: Value(TextBox16.Text),Worked:Value (TextInput13.Text),Vacation: Value(TextInput14.Text), Sick:Value(TextInput15.Text), Overtime:Value(TextInput16.Text),
Client:TextInput17.Text, Location:TextInput18.Text},
{Day: Value(TextBox17.Text),Worked:Value (TextInput19.Text),Vacation: Value(TextInput23.Text), Sick:Value(TextInput24.Text), Overtime:Value(TextInput25.Text),
Client:TextInput21.Text, Location:TextInput22.Text},
{Day: Value(TextBox18.Text),Worked:Value (TextInput31.Text),Vacation: Value(TextInput30.Text), Sick:Value(TextInput29.Text), Overtime:Value(TextInput28.Text),
Client:TextInput26.Text, Location:TextInput27.Text})

 

Formula for Submit button:
ForAll(TimeSheet,(Patch(TimeSheet_Week1,
{Day:Day,Worked: Worked,Vacation: Vacation,Sick:Sick,Overtime: Overtime,
Client: Client,Location: Location})))

Helpful resources

Announcements
Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Government Carousel

New forum: GCC, GCCH, DoD - Federal App Makers (FAM)

In response to the unique and evolving requirements of the United States public sector, Microsoft has created Power Apps US Government.

Users online (1,792)