cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Markxx60
Helper I
Helper I

Status field not updating

Hi all,

I have a simple app that keeps track of peoples licence status.

This forum kindly helped me with the code to update the status field depending on the date.

If( DataCardValue14.SelectedDate < Today() , "Expired",
DataCardValue14.SelectedDate <= DateAdd(Today(),30,Days), "Due Soon","Compliant")

What's happening is if I manually change the date it works perfectly but it doesn't change from Due Soon to Expired automatically.

But as soon as I click on edit form it does change.

I have a flow that sends out a email reminder at 30 days and again at 15 days but when it's Expired the the email doesn't get sent unless I intervene by clicking the edit form icon and then save.

Can I get some help please. I not a coder, thanks.

Markxx60_1-1642628539856.png

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Markxx60 ,

Sorry - no magic "hand of Power Apps" here. It is data in SharePoint and knows nothing about Power Apps, particularly when it is not running. Even when it is connected, you have to save the record in Power Apps to update it (the Default will work on the Text box, but still has to be saved).

As I mentioned, the Flow would need to query the data field with the same rules.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

 

 

View solution in original post

12 REPLIES 12
WarrenBelz
Super User
Super User

Hi @Markxx60 ,

Assuming you have the date saved in the List, you could do this

If(
   ThisItem.YourDateField < Today(),
   "Expired",
   ThisItem.YourDateField <= 
   DateAdd(
      Today(),
      30,
      Days
   ),
   "Due Soon",
   "Compliant"
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

Hi WarrenBelz,

Thanks for you reply, the expiry date is entered manually through the app and that updates a SharePoint list so the date is saved in the list. I put this code in the default section of the status field.

If(ThisItem.'Expiry Date' < Today(), "Expired",
ThisItem.'Expiry Date' <= DateAdd(Today(),30,Days),"Due Soon","Compliant") now when I manually change the expiry date the status box doesn't change were it did before. Is this because it's now pointing at the Sharepoint list and not the DataCardValue of the expiry date? I changed the date on the list and nothing happened after refreshing the list and the app I still had to click on the edit button before the status changed.

Sorry I'm just learning all this stuff 🙂

Hi @Markxx60 ,

You want it to show before and after changes? I think your issue may relate to this known bug which is currently causing a bit of havoc as your original code should work. This is a total workaround (and you should not have to do it), but at Screen OnVisible

UpdateContext({varExpiry: Blank()})

OnChange of the Date Picker

UpdateContext({varExpiry: Self.SelectedDate})

Your Default

With(
   {
      wDate:
      If(
         !IsBlank(varExpiry),
         varExpiry,
         ThisItem.'Expiry Date'
      )
   },
   If(
      wDate < Today(),
      "Expired",
      wDate <= 
      DateAdd(
         Today(),
         30,
         Days
      ),
      "Due Soon",
      "Compliant"
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

 

Hi @WarrenBelz , I really appreciate your time I changed the date on the list to be expired but it's still not changing. This is on the SharePoint list after refreshing the list

Markxx60_0-1642641353957.png

This is the Detail Screen

Markxx60_1-1642642135515.png

As soon as go to the edit screen it changes

Markxx60_2-1642642184192.png

That's with your latest fix. I took the OnVisible code to go into EditScree1 field or is this the wrong screen.

Hi @Markxx60 ,

I think we are talking about two different things here - you want the Status text box to update based either the current stored status or the Date Picker item if it is changed - I assume that is now happening. You still have to write that value back to SharePoint if you want it to change there - I assume it is being written from the Text Box?

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

Hi @WarrenBelz ,

Sorry if there is some confusion it's hard sometimes to put things into words.

I'll try and give a brief description on how this works. A license is issued for 12 months and the expiry date is entered via the date picker. The status (text input)DataCardValue is updated to show the license is compliant. 30 days out from expiry the status should change to Due Soon and at day 0 it should then change status to expired.

This ideally changes by its self and it does except for the expiring bit. I also have a flow working on the status to send a reminder email to the person about to lose their license. Sorry if this a bit long winded.

Hi @Markxx60 ,

Unfortunately, it will not change by itself unless you re-save the record (change or not). If you want to do this automatically, a Flow is the only way, but looking at the same date logic, not the Status which will remain as it was the last time you edited it. Is this what you are meaning?

Hi @WarrenBelz ,

Sorry I'm starting to get little bit lost. So the text input won't make that 3rd change? As it does change from Compliant to Due Soon it just doesn't do the 3rd change without manual intervention. So a flow would be better to update the text input based on the date picker?

Hi @Markxx60 ,

I don't think we are reading each other's minds here very well (and I have no idea on your Power Apps experience) - so I will ask a simple (apologies it is obvious) question. Are you expecting the Status column in SharePoint to be changed outside of saving the record in Power Apps ?

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

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