cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Sifu
Post Prodigy
Post Prodigy

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.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

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

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.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

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

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.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

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

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

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
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,592)