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})))

View solution in original post

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (377)