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

Set Review date and next review date

Hi, 

 

My requirement is for data (captured in a form) to be reviewed annually. 

 

So, I've created the New screen - where they will capture the information. My idea is to now create a view screen that has a button on that says do you want to review the data. If they click on the button it will go to the Edit screen. All good so far. 

 

The part I don't know is that I also want the Last Review date to then be set to today's date and the Next Review date to be set to 12 months after. 

 

(I will then also build a flow to remind the user to review the data when the next review date approaches)

 

Would really appreciate your advice.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Champion
Community Champion

Re: Set Review date and next review date

Hi @MadeleineDT ,

There are several possible ways of doing this, but I will go with a couple of Variables.

So you want to set the dates when the button is clicked? I will go with that in the code below

On the end of button code set two Variables and reset the fields

Set(vLast,Now());
Set(vNext,Now()+365);
Reset(LastReview);
Reset(NextReview)

On the Default of the two controls - I will call them LastReview and NextReview (replace with your control names) 

LastReview

If(
  !isBlank(vLast),
  vLast,
  Parent.Default
)

NextReview

If(
  !isBlank(vNext),
  vNext,
  Parent.Default
)

Finally on any screen exit code (save or cancel)

Set(vLast,Blank());
Set(vNext,Blank())

This also then allows for the screen to be opened in ways other than the button and show the current value

 

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.

 

View solution in original post

4 REPLIES 4
Highlighted
Community Champion
Community Champion

Re: Set Review date and next review date

Hi @MadeleineDT ,

There are several possible ways of doing this, but I will go with a couple of Variables.

So you want to set the dates when the button is clicked? I will go with that in the code below

On the end of button code set two Variables and reset the fields

Set(vLast,Now());
Set(vNext,Now()+365);
Reset(LastReview);
Reset(NextReview)

On the Default of the two controls - I will call them LastReview and NextReview (replace with your control names) 

LastReview

If(
  !isBlank(vLast),
  vLast,
  Parent.Default
)

NextReview

If(
  !isBlank(vNext),
  vNext,
  Parent.Default
)

Finally on any screen exit code (save or cancel)

Set(vLast,Blank());
Set(vNext,Blank())

This also then allows for the screen to be opened in ways other than the button and show the current value

 

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.

 

View solution in original post

Highlighted
Helper I
Helper I

Re: Set Review date and next review date

Hi @WarrenBelz,

 

Thank you so much for the code. I think it will work. 

 

Can I ask that you check my logic on the forms. 

Screen1 FormModeNew - applicability - you'll either leave the process or continue to the next screen

Screen2 FormModeNew - Risk assessment (This is the start of the assessment. I'm thinking I will set the default dates on this screen. And the exit code on the save button)

Screen3 FormModeNew - Security assessment (Should I be doing the exit code here too??? I'm worried I overwrite things)

Screen4 FormModeView - ALl the fields in view mode together with the button that says so you want to review

Screen5 &6 FormModeEdit - similar to 2 & 3 but in edit mode. 

 

What I think I'm asking is where is the best place to add the code?

 

Thank you so much!

Highlighted
Community Champion
Community Champion

Re: Set Review date and next review date

Hi @MadeleineDT ,

Thanks - to explain the logic.

Firstly I used a global variable as I was not sure of your screen navigation on this - you could use a screen variable (UpdateContext), but it really does not matter.

The only reason for the exit code is that you do not want to be going back to the screen on another record and having the possibility of the variable populating the field, particularly if you also use it to display data already written. Other than that the variable is a "one time use" value and simply needs to be reset after it has populated the box. Screen exit is a good time, but doing it on screen entrance as well (it will then always be Null initially), will always ensure you have to click the button to initiate it. As well, users seem to find all kinds of strange navigation methods you did not think of.

 

 

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.

 

Highlighted
Helper I
Helper I

Re: Set Review date and next review date

Oh ok - thank you so much!!!!

 

I have put the code in - will test it today but confident it will work. Thanks for taking the trouble

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 (8,678)