cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
New Member

Auto Select End Date field based on Start Date in Entity Appointment

Hi PowerApp Experts, 

 

I have a created a canvas app connected to D365. On the Entity, Appointment, I want to have a scenario, where on select of Start Date, the End Date also has to be filled with the same date. However, this does not seem to work. 

 

OnChange of Start Date, I have written the following code. 

 

If(
IsBlank(EndDateValue.SelectedDate),
UpdateContext( {selectedDate: StartDateValue.SelectedDate} ); Set(selectedDate, EndDateValue)

)

 

Can you please support me here?

 

Thanks a lot

SN.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Auto Select End Date field based on Start Date in Entity Appointment

Hi @SantoshNilla ,

I have made a test on my side, please take a try with the following workaround:

set the OnVisible property of the current screen to following:

Set(SelectedStartDate, Blank());
Set(IsEndDateBlank, false)

Set the OnChange property of the Start DatePicker control to following:

Set(
      SelectedStartDate,
      StartDatePicker.SelectedDate
);
If(IsBlank(EndDatePicker.SelectedDate), Set(IsEndDateBlank, true), Set(IsEndDateBlank, false))

Set the Default property of the End DatePicker control to following:

If(
   IsEndDateBlank = true,
   SelectedStartDate
)

Please consider take a try with above solution, 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.

View solution in original post

7 REPLIES 7
Highlighted
Super User
Super User

Re: Auto Select End Date field based on Start Date in Entity Appointment

Hi @SantoshNilla 

If you set the DefaultDate property of your End Date field to the SelectedDate from your Start Date field (e.g. dte_StartDate.SelectedDate), any changes to Start Date should update End Date.

 

2019-07-12_13-44-34.gif

 

Hope that helps

 


Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!


Follow me on Twitter at @QG_LeeJHarris

Or on LinkedIn at in/leejharris

Highlighted
Community Support
Community Support

Re: Auto Select End Date field based on Start Date in Entity Appointment

Hi @SantoshNilla ,

Based on the formula that you provided, I think there is something wrong with it.

 

Actually, it is not necessary to initialize a variable to store the selected date value within the Start Date Picker control. Instead, you could bind the Start DatePicker control and the End DatePicker control directly.

I have made a test on my side, please consider take a try with the following workaround:2.JPG

set the DefaultDate property of the End DatePicker control to following:

StartDatePicker.SelectedDate

Please check the following GIF screenshot for more details:Test.gif

 

If you want to store the selected Date value in your Start DatePicker control into a variable, please take a try with the following workaround:

Set the OnChange property of the Start DatePicker control to following:

Set(SelectedDate, StartDatePicker.SelectedDate)

Set the DefaultDate property of the End DatePicker control to following:

SelectedDate

Please consider take a try with above solution, 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.
Highlighted
New Member

Re: Auto Select End Date field based on Start Date in Entity Appointment

Hi @LeeHarris @v-xida-msft 

 

Thanks for your responses. Really appreciated. 

 

I already tried this out and it works. However I guess I missed to inform you a very important criteria, where it the problem actually arises.

 

The start date should be copied to end date only if the end date is not yet selected. 

 

When trying to use the IsBlank function, I am getting a cyclic redundency error. 

 

Thanks for your support, 

 

SN.

Highlighted
Super User
Super User

Re: Auto Select End Date field based on Start Date in Entity Appointment

Hi @SantoshNilla 

I think I have managed to get this working to meet your requirement.

For the purposes of this example I have two date fields, dte_StartDate and dte_EndDate.

 

dte_StartDate properties

DefaultDate: Today()

OnChangeIf(IsBlank(dte_EndDate.SelectedDate),UpdateContext({DefaultEndDate:dte_StartDate.SelectedDate}))

 

dte_EndDate properties

DefaultDateDefaultEndDate

 

You may also wish to have a "Reset Defaults" button that has an OnSelect value of UpdateContext({DefaultEndDate:Blank()})

 

Hope this helps.

 

 

 


Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!


Follow me on Twitter at @QG_LeeJHarris

Or on LinkedIn at in/leejharris

Highlighted
Community Support
Community Support

Re: Auto Select End Date field based on Start Date in Entity Appointment

Hi @SantoshNilla ,

I have made a test on my side, please take a try with the following workaround:

set the OnVisible property of the current screen to following:

Set(SelectedStartDate, Blank());
Set(IsEndDateBlank, false)

Set the OnChange property of the Start DatePicker control to following:

Set(
      SelectedStartDate,
      StartDatePicker.SelectedDate
);
If(IsBlank(EndDatePicker.SelectedDate), Set(IsEndDateBlank, true), Set(IsEndDateBlank, false))

Set the Default property of the End DatePicker control to following:

If(
   IsEndDateBlank = true,
   SelectedStartDate
)

Please consider take a try with above solution, 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.

View solution in original post

Community Support
Community Support

Re: Auto Select End Date field based on Start Date in Entity Appointment

Hi @SantoshNilla ,

Have you taken a try with the solution I provided above?

Have you solved your problem?

 

If you have solved your problem, please go ahead to click "Accept as Solution" to identify this thread has been 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.
Highlighted
New Member

Re: Auto Select End Date field based on Start Date in Entity Appointment

Hi @v-xida-msft 

 

I was able to perform the similar steps and I got it working.

 

Thanks a lot for your your support, @v-xida-msft  & @LeeHarris . Really appreciated. 

 

SN.

Helpful resources

Announcements
Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

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

Users online (7,922)