Can someone tell me why the below collection will not submit?
The issue is specifically with the column Five portion of the collection as it was submitting before I added this.
The patch code has the red X beside the submit button, but it isn’t clear why it’s wrong. If I view the collection I can see the date stored there just fine.
Collection code:
Collect(Col1, {One: Country_1.Selected.Value, Two: Text(DateOut_1.SelectedDate,"dd/mm/yyyy"), Three: Text(DateBack_1.SelectedDate,"dd/mm/yyyy"), Four: Reason_1.Selected.Value, Five: Text(Today(),"dd/mm/yyyy")})
Submit button OnSelect code:
Patch('Travel Notification', ForAll(Col1 As _Data,{Destination: _Data.One, Date_Departure: _Data.Two, Date_Return: _Data.Three, Reason: _Data.Four, Date_Created: _Data.Five}));
Hi @elfreddos
Assuming that the data types of Date_Departure and Date_Return are dates, you would need to call DateValue to convert the Text dates to Date objects:
Patch('Travel Notification',
ForAll(Col1 As _Data,{Destination: _Data.One, Date_Departure: DateValue(_Data.Two), Date_Return: DateValue(_Data.Three), Reason: _Data.Four, Date_Created: DateValue(_Data.Five)})
);
As I mentioned in your other post, saving DatePicker.SelectedDate to a collection saves a Date object to the collection. I would recommend that you stick with this approach. If you're seeing US dates in the collection view, the probable reason for this is that your browser is set to US English.
If you build the collection like so, the Patch should hopefully work.
Collect(Col1, {One: Country_1.Selected.Value, Two: DateOut_1.SelectedDate,
Three: DateBack_1.SelectedDate, Four: Reason_1.Selected.Value,
Five: Today()})
Patch('Travel Notification', ForAll(Col1 As _Data,{Destination: _Data.One, Date_Departure: _Data.Two, Date_Return: _Data.Three, Reason: _Data.Four, Date_Created: _Data.Five}));
hey @elfreddos
for collection try:
Collect(Col1, {One: Country_1.Selected.Value, Two: Text(DateOut_1.SelectedDate,"dd/mm/yyyy"), Three: Text(DateBack_1.SelectedDate,"dd/mm/yyyy"), Four: Reason_1.Selected.Value, Five: Text(Today(),"dd/mm/yyyy")})
patch:
Patch('Travel Notification', ForAll(Col1 As _Data,{Destination: _Data.One, Date_Departure: _Data.Two, Date_Return: _Data.Three, Reason: _Data.Four, Date_Created: _Data.Five}));
Let me know if my answer helped solving your issue.
If it did please accept as solution and give it a thumbs up so we can help others in the community.
Greetings
Could you please show me error details?
Thanks for that! The column is a date/time column in SharePoint but with Date Only display.
Unfortunately, that code you sent over also doesn't work. It throws up a red line from the "patch" portion.
Hi @elfreddos ,
Do you mean that Patch function doesn't work?
Could you please tell me the type of Date_Created column and database?
Or you can try this first:
ForAll(Col1 As _Data,Patch('Travel Notification',Defaults('Travel Notification'),{Destination: _Data.One, Date_Departure: _Data.Two, Date_Return: _Data.Three, Reason: _Data.Four, Date_Created: _Data.Five}));
Best regards,
Rimmon