cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Cooper01
Responsive Resident
Responsive Resident

Clearing a date picker when DefaultDate property is already being used?

I know to clear a date picker you could set the DefaultDate picker to a variable and then clear the variable on some other action and reset the date picker to clear the selected date.

My date picker is on an edit form (not a true Power Apps form) so the DefaultDate needs to be whatever the user selected.

What is the best way to clear this value?

1 ACCEPTED SOLUTION

Accepted Solutions
Cooper01
Responsive Resident
Responsive Resident

I am not using a standard Power Apps form so I am not able to use the Parent values. I added an X icon with the following OnSelect

UpdateContext({locResetDate: true}); Reset(DatePickerControl)

and changed the DefaultDate in the date picker to 

If(!locResetDate, [original date])

 

View solution in original post

6 REPLIES 6
v-yangar-msft
Microsoft
Microsoft

Hi @Cooper01 ,

 

Could you tell me:

  1. Whether you use the custom form in sharepoint list?
  2. Do you want to clear the default date value of DatePicker in Edit Form and don’t display any date in the datepicker?

 

I assume that :

1.You use the custom form in SharePoint list.

2.You want to clear the default date value of DatePicker in Edit Form and don’t display any date in the datepicker.

If so, firstly, fields in the EditForm pick it source from the database. So if the connected table in the database for the date is not blank, then there will be a date in datepicker in EditForm.

Therefore, you can clear the default date when you use the datepicker in edit form via setting the DefaultDate property of datepicker to:

If(EditFormName.Mode=FormMode.Edit,Blank(),Parent.Default)

Then you will find the default date value in the date picker will be the value of InputTextPlaceholder property as below:

v-yangar-msft_0-1611909821145.png

 

So just clear the value of InputTextPlaceholder and you will find that you have cleared this selected date.

v-yangar-msft_1-1611909821148.png

 

 

If I have any misunderstanding, please correct me.

 

Hope it helps!

 

Best Regards,

Arrow

Thank you for the response. This is not using SharePoint as the data source, it is Dataverse. There is no Power Apps form being used, basically I have a gallery with a list of items from a table. I click on the item and set selected to a global var and navigate to a different screen. Then the date picker default is SelectedItemGlobalVar.MyDateFieldValue

Hi @Cooper01 ,

 

Welcome!

As your description, I add a gallery and set an entity in Dataverse as the data source.

v-yangar-msft_0-1612161066589.png

When i click the item an it will navigate to another screen as below:

v-yangar-msft_1-1612161159411.png

Do you want to clear this value in my screenshot?

If i have any misunderstanding, please feel free to let me know.

 

Thanks,

Arrow

Yes that's correct this is what I'm looking to clear

v-yangar-msft
Microsoft
Microsoft

Hi  @Cooper01 ,

 

Thanks for your reply.

Whether you want to clear the DatePicker but keep the DefaultDate.

If so, you have to add an extra Remove button in the data card to clear the selected date. Please refer to the following steps:

1.Unlock the data card, insert a Cancel icon

2.Set Icon.OnSelect: 

 

Set(vardate,Blank())

 

3.Set DatePicker.DefaultDate: 

 

If(IsBlank(vardate),vardate,Parent.Default)

 

4.Set DatePicker.OnChange: 

 

Set(vardate,1)

 

5.Enable the "Formula Level error management" in Advanced Setting. (Important!)

111.png

 

 

Best Regards,

Arrow

 

Cooper01
Responsive Resident
Responsive Resident

I am not using a standard Power Apps form so I am not able to use the Parent values. I added an X icon with the following OnSelect

UpdateContext({locResetDate: true}); Reset(DatePickerControl)

and changed the DefaultDate in the date picker to 

If(!locResetDate, [original date])

 

View solution in original post

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

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

Power Apps June 2021

June Power Apps Community Call

Did you miss the call? Check out the recording here!

Top Solution Authors
Top Kudoed Authors
Users online (36,685)