Hi,
I have a gallery with a button which is collecting data and it has the following function inside (see below). When I populate the first row (For instance: 12-4-2020) and I click, it changes the date once it adds the second row.
Patch(CCPayments, ThisItem, {Date: DateValue(IDate.Text), Comprobante: IComprobante.Text, }); Collect(CCPayments, {Date: "", Comprobante:""})
Any idea on why is this happening?
Thank you
Solved! Go to Solution.
Hi @bolandre92 ,
I have the problem - requires a bit of lateral logic as you cannot just have Today() as a Default and still display the current value (you need one or the other, hence it briefly appears. It has actually been written to the collection, but you cannot see it.
So try this in the Default of the DatePicker iDate
If(
IsBlank(ThisItem.Comprobante),
Today(),
ThisItem.Date
)
Incidentally, Date is not a good name for a field - can lead to ambiguity.
I also got an error trying to create a blank date - you actually only need one field
Collect(
CCPayments,
{Comprobante:""}
)
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
Hi @bolandre92 ,
I am assuming your gallery is based on the Collection CCPayments and that the control ODate has some sort of free-typed date.
You have not said where this code is being run from, but it would need to be from a control inside either the gallery (which I think is the case) or a form based on the item selected in the gallery.
If this is the case, your code
Patch(
CCPayments,
ThisItem,
{
Date:DateValue(IDate.Text),
Comprobante: IComprobante.Text
}
)
will update the current selected item with the Date to whatever is typed in the IDate control and the other field the same
The next bit
Collect(
CCPayments,
{
Date: "",
Comprobante:""
}
)
will add a blank record to the gallery.
If all this is correct (please elaborate if not), how and when is the date changing and to what?
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
Hi,
You are totally correct, thank you.
The date picker field is configured as "Defaultdate = Today()"
So when I type information in the two fields (for instance: {Date 04-15-2020 and Comprobante: 400200} and then I click the button with the underlying code, indeed It adds a blank record to the gallery but it also updates the date of the first record as todays date. instead of leaving the date typed initially (04-15-2020)
I hope this gives you enough information.
Hi @bolandre92 ,
My assumptions were not totally correct - you have mentioned a Date Picker here (I described a text box with a typed date)
Two things - look at the Default value and remove Today() as this is causing the issue.
Secondly, if you are dealing with the output of a Date Picker, the code should be
Patch(
CCPayments,
ThisItem,
{
Date:iDate.SelectedDate,
Comprobante: IComprobante.Text
}
)
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
Hi,
I have removed the "Today()" and have updated the the function as you have described below and the issue continues. Once I click the button the first record already typed, updated it date to 12-31-2001 instead of today's date.
Thank you.
Hi @bolandre92 ,
That is not the entered date - that is the InputTextPlaceHolder which shows the user what format to expect - remove the setting and it will be blank.
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
I have followed your instructions accordingly, however, once I click the button (which contains the following code), the first row continues changing the date. The collection captures the date initially entered but the gallery changes the date of the first row which is very weird.
Patch(CCPayments, ThisItem, {Date: IFecha.SelectedDate, Comprobante: IComprobante.Text, }); Collect(CCPayments, {Date: "", Comprobante:""})
Thank you
Hi @bolandre92 ,
UPDATE
Looking at your code, there are actually two quite separate issues. Firstly as per my last post, 12-31-2001 is not an entry that will save - you will get a blank date - I always remove it from InputTextPlaceHolder as it confuses users.
However your problem is another issue. Can you please send me a screenshot of what you are doing and importantly, I need to know where you are running this code from (button in gallery, OnChange of control etc).
Also are you expecting Today() to be the Default that a user can change and what happened after you added the date picker control code - did it update the record properly?
Our messages crossed here - you have given me some of the information, but I still need to see it to better understand your process. Also what is the Items property of the Gallery?
See two screenshots attached.
Dates are in blank so that the user does not get confused. the button is in the gallery where the records are entered. You can see in the first capture that the date has been entered and once the button + is clicked the date disappear.
Thank you.
User | Count |
---|---|
252 | |
126 | |
104 | |
50 | |
50 |