cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Cooper01
Continued Contributor
Continued Contributor

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
Continued Contributor
Continued Contributor

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

Cooper01
Continued Contributor
Continued Contributor

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

Cooper01
Continued Contributor
Continued Contributor

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
Continued Contributor
Continued Contributor

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])

 

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (2,433)