cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SantoshNilla
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

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
LeeHarris
Solution Sage
Solution Sage

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

v-xida-msft
Community Support
Community Support

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.
SantoshNilla
New Member

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.

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

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

v-xida-msft
Community Support
Community Support

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
New Member

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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Kudoed Authors
Users online (49,409)