cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
_kikilalaaa
Level: Powered On

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
_kikilalaaa
Level: Powered On

Re: Empty Value for date

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
Level 8

Re: Empty Value for date

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
Level 8

Re: Empty Value for date

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

_kikilalaaa
Level: Powered On

Re: Empty Value for date

Hi, to answer your question:

1. I use SubmitForm
2. The default = ThisItem.ExpiryDate
_kikilalaaa
Level: Powered On

Re: Empty Value for date

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.
PowerAddict
Level 8

Re: Empty Value for date

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)
_kikilalaaa
Level: Powered On

Re: Empty Value for date

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
_kikilalaaa
Level: Powered On

Re: Empty Value for date

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
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 130 members 5,433 guests
Please welcome our newest community members: