cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
martinav
Resident Rockstar
Resident Rockstar

Patch() statement not working in a Timer control OnTimerEnd

I have a statement that is working great as an OnSelect control.  However, I wish for this routine to run every 15minutes.  It is a collection refresh routine that updates my collection if any of my datasources have had any updates.  I can use it in a reload "button", but as an OnTimerEnd control, it does not show as legit.  Any specific hate for Patch() specifically in a timer??  The statement is even quite happy in the OnSelect of the timer.  Just not in the timer end control.  Helpie??

 

image.pngFull Statement:

UpdateContext({LoadDataSpinner:true,Circle1_Color:Red,Circle2_Color:Red,Circle3_Color:Red});

Concurrent(
Clear(UpdatedFromMDL),Clear(UpdatedAcct),Clear(UpdatedAcctProd),Clear(UpdatedAcctData),Clear(UpdatedMDL),
UpdateContext({TimerReset:false, Circle1_Color:Green})
);

Concurrent(Refresh('Engineering Change Notice'), Refresh('Engineering Change Request'), Refresh(Drawing_Vault),
If(CountRows(ClearCollect(UpdatedMDL,Filter(SortByColumns(Master_Drawing_List,"Modified",Descending),Modified>LastUpdate)))>0,UpdateContext({No_MDL_Updates:false}),UpdateContext({No_MDL_Updates:true})),

If(CountRows(ClearCollect(UpdatedAcct,Filter(SortByColumns('[dbo].[tbINVTransactionDetail]',"PostedTimestamp",Descending),DateTimeValue(Text(PostedTimestamp))>DateAdd(LastUpdate,-DateDiff(Now(), DateAdd(Now(),TimeZoneOffset(),Minutes),Hours),Hours))))>0,UpdateContext({No_Acct_Updates:false}),UpdateContext({No_Acct_Updates:true})),

If(CountRows(ClearCollect(UpdatedAcctProd,Filter(SortByColumns('[dbo].[VIEW_POWERAPPS_BASIC_ACCTIVATE_DATA]',"UpdatedDate",Descending),DateTimeValue(Text(UpdatedDate))>DateAdd(LastUpdate,-DateDiff(Now(), DateAdd(Now(),TimeZoneOffset(),Minutes),Hours),Hours))))>0,UpdateContext({No_AcctProd_Updates:false}),UpdateContext({No_AcctProd_Updates:true}))

);

Collect(UpdatedAcct,UpdatedAcctProd);

UpdateContext({Circle2_Color:Green});

Concurrent(
ClearCollect(UpdatePartNumbers,UpdatedMDL.MD_PartNumber,RenameColumns(UpdatedAcct,"ProductID","MD_PartNumber").MD_PartNumber,RenameColumns(UpdatedAcctProd,"ProductID","MD_PartNumber").MD_PartNumber),

ForAll(UpdatedAcct.ProductID,Collect(UpdatedAcctData,LookUp(RenameColumns('[dbo].[VIEW_POWERAPPS_BASIC_ACCTIVATE_DATA]',"ProductID","Acct_PartNumber"),Acct_PartNumber=ProductID)))
);

UpdateContext({Circle3_Color:Green});

ForAll(Distinct(UpdatePartNumbers,MD_PartNumber).Result,Collect(UpdatedFromMDL,LookUp(Master_Drawing_List,MD_PartNumber=Result)));

ForAll(RenameColumns(UpdatedFromMDL,"MD_PartNumber","MD_PartNumber2"),

   Patch(MDL_All,LookUp(MDL_All,MD_PartNumber=MD_PartNumber2),
      {
          MD_Project: MD_Project, 
          MD_LatestRevNumber: MD_LatestRevNumber, 
          MD_EngrgRelDate: MD_EngrgRelDate, 
          Title: Title, 
          MD_PDM_Link: MD_PDM_Link, 
          MD_LinkToDrawing: MD_LinkToDrawing, 
          MD_IsActive: MD_IsActive, 
          MD_Data_Flagged: MD_Data_Flagged,  
          MD_Latest_SW_DocumentID: MD_Latest_SW_DocumentID, 
          LastCost:LookUp(UpdatedAcctData,Acct_PartNumber=MD_PartNumber2,LastCost), 
          OnHand: LookUp(UpdatedAcctData,Acct_PartNumber=MD_PartNumber2,OnHand), 
          Location_Acct: LookUp(UpdatedAcctData,Acct_PartNumber=MD_PartNumber2,Location), 
          Discontinued_Acct: LookUp(UpdatedAcctData,Acct_PartNumber=MD_PartNumber2,Discontinued), 
          Available: LookUp(UpdatedAcctData,Acct_PartNumber=MD_PartNumber2,Available)
       }
    )
);
    
Set(LastUpdate,Now()-.002);

UpdateContext({TotalDwgCount:CountRows(MDL_All),LoadDataSpinner:false});

ClearCollect(StockQuote,GetKIQStockQuote.Run());

UpdateContext({LastStockUpdate:Now()})
4 REPLIES 4
RandyHayes
Super User III
Super User III

@martinav 

Just saw this posting...

I think you might be looking to throw this out into the other suggestion of a toggle control.  See if you have any other luck with that. 

 

_____________________________________________________________________________________
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

@RandyHayes 


Yes.  I did move into the other methhods when I hit this wall.  I'm still curious why the patch() is not happy in the timer.  

 

The interesting thing is that using the method with Select(Label) in the OnTimerEnd works fine.  Its quite strange.

@martinav 

That is odd.  I am not aware of any restrictions on the timer actions.

_____________________________________________________________________________________
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
v-xida-msft
Community Support
Community Support

Hi @martinav ,

Please consider take a try to modify your formula as below:

UpdateContext({LoadDataSpinner:true,Circle1_Color:Red,Circle2_Color:Red,Circle3_Color:Red});
Concurrent(
Clear(UpdatedFromMDL),Clear(UpdatedAcct),Clear(UpdatedAcctProd),Clear(UpdatedAcctData),Clear(UpdatedMDL),
UpdateContext({TimerReset:false, Circle1_Color:Green})
);
...

...

ForAll(Distinct(UpdatePartNumbers,MD_PartNumber).Result,Collect(UpdatedFromMDL,LookUp(Master_Drawing_List,MD_PartNumber=Result)));

ForAll(                      /* <-- Modify formula here */
UpdatedFromMDL, Patch(
MDL_All,
LookUp(MDL_All,MD_PartNumber = UpdatedFromMDL[@MD_PartNumber2]), { MD_Project: UpdatedFromMDL[@MD_Project], MD_LatestRevNumber: UpdatedFromMDL[@MD_LatestRevNumber], MD_EngrgRelDate: UpdatedFromMDL[@MD_EngrgRelDate], Title: UpdatedFromMDL[@Title], MD_PDM_Link: UpdatedFromMDL[@MD_PDM_Link], MD_LinkToDrawing: UpdatedFromMDL[@MD_LinkToDrawing], MD_IsActive: UpdatedFromMDL[@MD_IsActive], MD_Data_Flagged: UpdatedFromMDL[@MD_Data_Flagged], MD_Latest_SW_DocumentID: UpdatedFromMDL[@MD_Latest_SW_DocumentID], LastCost:LookUp(UpdatedAcctData,Acct_PartNumber = UpdatedFromMDL[@MD_PartNumber2], LastCost), OnHand: LookUp(UpdatedAcctData,Acct_PartNumber = UpdatedFromMDL[@MD_PartNumber2],OnHand), Location_Acct: LookUp(UpdatedAcctData,Acct_PartNumber = UpdatedFromMDL[@MD_PartNumber2],Location), Discontinued_Acct: LookUp(UpdatedAcctData,Acct_PartNumber = UpdatedFromMDL[@MD_PartNumber2], Discontinued), Available: LookUp(UpdatedAcctData,Acct_PartNumber = UpdatedFromMDL[@MD_PartNumber2], Available) } ) ); Set(LastUpdate,Now()-.002); UpdateContext({TotalDwgCount:CountRows(MDL_All),LoadDataSpinner:false}); ClearCollect(StockQuote,GetKIQStockQuote.Run()); UpdateContext({LastStockUpdate:Now()})

Please take a try with above formula, then check if the issue is solved.

 

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.

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza Winner Announcement

Please join us on Wednesday, July 21st at 8a PDT. We will be announcing the Winners of the Demo Extravaganza!

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

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.

Top Solution Authors
Top Kudoed Authors
Users online (3,606)