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

7 REPLIES 7
PowerAddict
Super User II
Super User II

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 III
Super User III

@_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"

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 Winner Announcement

Please join us on Wednesday, July 21st at 8a PDT. We will be announcing the Winners of the Demo Extravaganza!

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (1,980)