cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SantoshNilla
Level: Power Up

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
Community Support Team
Community Support Team

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
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!


Community Support Team
Community Support Team

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
SantoshNilla
Level: Power Up

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.

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!


Community Support Team
Community Support Team

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 Team
Community Support Team

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.
SantoshNilla
Level: Power Up

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
thirdimage

Power Automate 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

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Users Online
Currently online: 299 members 4,675 guests
Please welcome our newest community members: