cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
_kikilalaaa
Helper V
Helper V

Empty Value for date

Hi All. 

 

I am trying to make a form to check whether the food has expired. In the form there are 2 datacard: "Has Expired" and "Expiry Date". 

The "Expiry Date" datacard will be only visible if user select "Yes" for "Has Expired" datacard. This form will be submitted and the data will be stored in sharepoint list. Then, user can view the form that they have submit.

 

The problem I am facing is that when the user select "No", the sharepoint list still update the default date. How to make it empty?

 

1. I have tried to clear the date inputtextholder properties. However, this also cleared the date enter by user when they select "Yes", when they view the form.

 

p/s: I am still new in PowerApps. Hope the experts can help me.

1 ACCEPTED SOLUTION

Accepted Solutions

Hiii all!

I have figured it out. Apparently my mistake was I set the Date data type in the Sharepoint as date and time.

How I fix it:

1. Set the data type for date in Sharepoint as single line text
2. Add Datepicker in Date datacard in PowerApps. So now, you supposed to have 2 fields in the same datacard; datepicker and textfield.
3. Textfield:Default = Blank()
4. Date DataCard: Update = If(radio. Selected. Value ="Yes", DatePicker. SelectedDate, Textfield.Text)
5. Date DataCard:Visible = Radio. Selected. Value = "yes"

View solution in original post

10 REPLIES 10
PowerAddict
Super User
Super User

Hi,

A few questions:

1. What are you using to submit the form? SubmitForm or Patch?

2. What is the default property of the expiry date card?

If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

Hardit(Haman)
mdevaney
Super User
Super User

@_kikilalaaa 

I would suggest using this code in the Update property of your DataCard for ExpiryDate.  When the Has Expired toggle shows "Yes" the selected expiry date will be updated in Sharepoint and when "No" the expired date will be updated as a blank field.

 

If(
    toggle_HasExpired.Value=True,
    DataCardValue_ExpiryDate.SelectedDate,
    Blank()
);

 

Another tip: it would be a good idea only to show the Expiry Date datepicker when Has Expired is True.  To do that put this code in the Visible property of the Expiry Date datacard.

 

toggle_HasExpired.Value

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Hi, to answer your question:

1. I use SubmitForm
2. The default = ThisItem.ExpiryDate

Hi, I have tried this method but it still show the present date. I think maube I need to change the default but I don't know what to replace it with.

You can try 2 things:

1. Add the if condition in the default property of the date card to only have a default if the has expired is set to yes, OR

2. If you can use Patch instead of SubmitForm, you can control what values you want to update when directly in your formula.

Let me know if either works.

---
If you like this reply, please give kudos. And if this solves your problem, please accept this reply as the solution. Thanks!

Hardit(Haman)

Hi, I have tried the first option but it doesn't work. I haven't try ysing patch before. So I'll try that first and tell you whether it works. Thanksss

Hiii all!

I have figured it out. Apparently my mistake was I set the Date data type in the Sharepoint as date and time.

How I fix it:

1. Set the data type for date in Sharepoint as single line text
2. Add Datepicker in Date datacard in PowerApps. So now, you supposed to have 2 fields in the same datacard; datepicker and textfield.
3. Textfield:Default = Blank()
4. Date DataCard: Update = If(radio. Selected. Value ="Yes", DatePicker. SelectedDate, Textfield.Text)
5. Date DataCard:Visible = Radio. Selected. Value = "yes"
fbeauchesne
New Member

I struggled with the same issue.

You have to go into the column setting and select (None) as Default value.

takolota
Super User
Super User

None of these answers worked for me and I really did not want to recreate the date columns in separate text columns.

I had to use this formula on the submit button:

 

SubmitForm(Form1); If(Or(IsBlankOrError(DataCardValue8.SelectedDate), IsBlankOrError(DataCardValue9.SelectedDate)), RecordsRetentionSetNullDates.Run(RecordsRetentionList.Selected.ID, IsBlank(DataCardValue8.SelectedDate), IsBlank(DataCardValue9.SelectedDate)), "");

 

 

And set up a corresponding flow to input those null values in the date fields.

takolota_0-1646780447245.png

 

Helpful resources

Announcements
Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Government Carousel

New forum: GCC, GCCH, DoD - Federal App Makers (FAM)

In response to the unique and evolving requirements of the United States public sector, Microsoft has created Power Apps US Government.

Users online (2,049)