cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Super User
Super User

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
Super User
Super User

Re: Patch() statement not working in a Timer control OnTimerEnd

@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. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Super User
Super User

Re: Patch() statement not working in a Timer control OnTimerEnd

@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.

Super User
Super User

Re: Patch() statement not working in a Timer control OnTimerEnd

@martinav 

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

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Community Support Team
Community Support Team

Re: Patch() statement not working in a Timer control OnTimerEnd

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
thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (5,992)