cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper II
Helper II

TemplateFill If statement not updating

I have a Gallery I use with this formula on a Sharepoint list on the TemplateFill ttribute

 

If(Created > Now()- 5/(24*60),Green,Created > Now()- 10/(24*60),Blue,Red)

This formula works great but only works when the app is loaded. It does not refresh the colors even if I go into another page and come back, only way to refresh the colors is to close the app and go back in.


I also created a timer that refresh the Sharepoint list every 10 seconds which works as planned because new items are added with the right color scheme.

 

Any way to make the gallery check for the TemplateFill formula every 10 seconds like the Sharepoint List?

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: TemplateFill If statement not updating

@yanni99 

Ah, I see, you need a reference point for this to happen.  Now() will only be evaluated at that point in time.  You need something that continues to update. Your refresh on the datasource should do the trick, but I will simply cut to the chase and have attached a sample app that will demonstrate the reference point and all of this working together.

 

Download and save the attached app.  In PowerApp designer, open or create an app.  Once in that app, click on File->Open->Browse and selected the file you downloaded.

 

This sample will give you 4 aged records colors all based on the time (see the TemplateFill property).

If you run the App, it will continuously update the reference time in a variable.  This will cause the template fill to evaluate based on that. 

If you watch it for a few minutes, you will see that within a minute (as that's how I made the sample data - see App.OnStart) the colors will change with no other actions (refreshes or anything) needed.

Every minute, the list will have one more item added to it to continuously show new items and simulate a refresh.

 

Take a look and see if you have any questions from that.  Also, this demo shows the use of the DateDiff in the calculations.

 

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

View solution in original post

6 REPLIES 6
Highlighted
Super User
Super User

Re: TemplateFill If statement not updating

@yanni99 

I'm not clear from your question if you are having an issue with the TemplateFill or with refreshing data to your list.

If it's an issue with the TemplateFill, my first question would be - what is "Created" in your formula?  Is this a variable some place or some other value you are using?  If it is intended to be the current record's 'Created' column, then you will want to modify your formula to this:

If(ThisItem.Created > Now()- 5/(24*60),Green, ThisItem.Created > Now()- 10/(24*60), Blue, Red)

(also - not addressing it in this reply, but you should really consider using the DateAdd and/or DateDiff functions for your date calculations rather than straight math.) 

 

If the refresh is your real issue, then if you are expecting the list to change when the underlying data source changes, then setting a timer is really one of the only options.

 

I hope this is helpful for you.

_____________________________________________________________________________________
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.
Highlighted
Helper II
Helper II

Re: TemplateFill If statement not updating

Thank you @RandyHayes  for this reply.

 

Yes the formula is ThisItem.created pulled from Sharepoint. The Formula works great. It is just not updating the Color Scheme in set TemplateFill.

 

The Items are updating constantly, just not the color. Once it's there, it is never changing color depending on my formula. You have to close the app an open it back for the TemplateFill formula to take effect.

 

Thank you I'll look into DateDiff and DateAdd.

Highlighted
Super User
Super User

Re: TemplateFill If statement not updating

@yanni99 

So then I believe what you are saying is that, take one item for example, the color is a specific color based on your formula.  Then the item is changed in the SharePoint list, but the color does not change in your App.  

If this is correct, then, yes, this is a Refresh issue.  PowerApps is not constantly "connected" to the list.  It only gathers once and then you would need to invoke a Refresh for it to go get it again (or re-enter the app).

_____________________________________________________________________________________
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.
Highlighted
Helper II
Helper II

Re: TemplateFill If statement not updating

Thank you for the reply

 

I will try to show you, so you see in this screenshot, one is green and one is yellow based on time from my formula on the Gallery 5 and less minutes is green, between 5 and 10 minutes it's yellow, else is red. Date shown is date that the item have been created in Sharepoint. Works great when you start the app. But if I stay in this window for 5 - 10 - 15 minutes, even though the data is refreshing every 10 seconds and new items are populated, it will never change color. 

2019-06-27 10_59_33-POS-001099 - ConnectWiseControl - Connected.png

 

But if I close the app and reopen it, the colors will all have updated.

 

The purpose is to, from one quick peep, tell how long the item have been in the list to take action rapidly.

 

Highlighted
Super User
Super User

Re: TemplateFill If statement not updating

@yanni99 

Ah, I see, you need a reference point for this to happen.  Now() will only be evaluated at that point in time.  You need something that continues to update. Your refresh on the datasource should do the trick, but I will simply cut to the chase and have attached a sample app that will demonstrate the reference point and all of this working together.

 

Download and save the attached app.  In PowerApp designer, open or create an app.  Once in that app, click on File->Open->Browse and selected the file you downloaded.

 

This sample will give you 4 aged records colors all based on the time (see the TemplateFill property).

If you run the App, it will continuously update the reference time in a variable.  This will cause the template fill to evaluate based on that. 

If you watch it for a few minutes, you will see that within a minute (as that's how I made the sample data - see App.OnStart) the colors will change with no other actions (refreshes or anything) needed.

Every minute, the list will have one more item added to it to continuously show new items and simulate a refresh.

 

Take a look and see if you have any questions from that.  Also, this demo shows the use of the DateDiff in the calculations.

 

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

View solution in original post

Highlighted
Helper II
Helper II

Re: TemplateFill If statement not updating

@RandyHayes 

Thank you, this is exactly what I needed. 

 

Solution is a OnTimerEnd that sets a variable with now whenever you want to refresh it.

 

Excellent work.

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,777)