cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Sifu
Continued Contributor
Continued Contributor

Running 2x patch after each other wont work properly

i have an app in SPO that records values entered by users to a SPO List... because in most cases users should enter only some values(work) and very rarely other values (travel) i flag the items with these two flags... so i can patch only those values that have changed... one item has work as well as trip but rarely both are changed...

when i run the save button with this, it will change all values for Time (first part) but only first value of Trip, no idea why

 

 

//patching values to tna table if work time changed
ForAll(RenameColumns(Filter(Gallery3.AllItems,'changed-work'.Value=true), "ID", "ID2"),
Patch('Attendance Calendar', LookUp('Attendance Calendar',ID=ID2),
      { StartTime:If(IsBlank(from.Text),Blank(),from.Text), EndTime: If(IsBlank(to.Text),Blank(),to.Text), TimeAtWork: If(IsBlank(hoursworked.Text),Blank(),Value(hoursworked.Text)), BreakInHours: If(IsBlank(break.Text),Blank(),Value(break.Text)) } ));
      
//patching values to tna table if travel time changed
ForAll(RenameColumns(Filter(Gallery3.AllItems,'changed-trip'.Value=true), "ID", "ID2"),
Patch('Attendance Calendar', LookUp('Attendance Calendar',ID=ID2),
      { PassiveTravelTimeStart: If(IsBlank(pttstart.Text),Blank(),pttstart.Text), PassiveTravelTimeEnd: If(IsBlank(pttend.Text),Blank(),pttend.Text), PassiveTravelTimeDurringWorkTime: If(IsBlank(pttdw.Text),Blank(),pttdw.Text) } ));

 

 

7 REPLIES 7
RandyHayes
Super User
Super User

@Sifu 

Since it appears that you are trying to set columns to Blank(), make sure that you have the "Formula-level error management" turned on in your advanced settings. 

 

Also you can consider refactoring your formula to the following for a little better performance and maintainability:

//patching values to tna table if work time changed
ForAll(
    RenameColumns(
        Filter(Gallery3.AllItems,'changed-work'.Value), 
        "ID", "ID2"
    ),
    UpdateIf('Attendance Calendar', ID=ID2,
       { StartTime:from.Text, EndTime: to.Text, TimeAtWork: Value(hoursworked.Text), BreakInHours: Value(break.Text) } 
    )
);
      
//patching values to tna table if travel time changed
ForAll(
    RenameColumns(
        Filter(Gallery3.AllItems,'changed-trip'.Value), 
        "ID", "ID2"
    ),
    UpdateIf('Attendance Calendar', ID=ID2,
       { PassiveTravelTimeStart: pttstart.Text, PassiveTravelTimeEnd: pttend.Text, PassiveTravelTimeDurringWorkTime: pttdw.Text } 
    )
);

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
Sifu
Continued Contributor
Continued Contributor

thanks @RandyHayes  but this works only if i dont exceed 2000 lines as far i see (it was not working when i set the row limit to 30)

RandyHayes
Super User
Super User

@Sifu 

Are you referring to the UpdateIf?  If so, it is fully delegable with the formula I provided, so there should be no issues with limits.  Or are you referring to some other error/issue you are seeting?

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
Sifu
Continued Contributor
Continued Contributor

yes to the udpate if... if i set the row limit to extreme 30 rows it was not changing values....

RandyHayes
Super User
Super User

@Sifu 

I am not seeing that issue.  Just in case there has been some new version that was breaking what should work, I just performed a simple test.  SharePoint list has 23 items in it.  Record limit set to 10.  UpdateIf(source, ID=19, {....}) worked perfectly!

So that is fine.  There has to be some other factor in your formula that is causing the issue.  So, regarding the formula that I replied with, which part is having the issue, the first block or the second?

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
Sifu
Continued Contributor
Continued Contributor

i cant really tell which part is the problem, will look into it tomorrow again if i figure out i let you know

Sifu
Continued Contributor
Continued Contributor

i have no idea:

 

the gallery items:

Filter('Attendance Calendar',UPN=upn_label_5.Text, YearMonth=Dropdown_month.SelectedText.Result)

(UPN_LABEL_5 is just UPN of a user)

YearMonth is a dropdown:

Distinct(Filter('Attendance Calendar',MonthlyApproval="Open", UPN=upn_label_5.Text).YearMonth,YearMonth).Result

 

but never mind, i give up on this, since its not such tragedy of time. thanks for your effort

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,491)