mrackley / StratusForms

Lightweight InfoPath alternative for SharePoint 2007,2010,2013,2016,2019 and Office 365
82 stars 36 forks source link

DateFields #17

Open btroop202 opened 6 years ago

btroop202 commented 6 years ago

Good day, I have a JS date field picker which works fine, but if I open to edit is subtracts one day each time i open to edit and save.

So I have code when the form opens to format the date field, because it trys to add time which then causes a issue on save. So it is display the right date, but when I save it subtracts one, then when I open it now shows the new data.

var date = ($("#DEROS").val()); if (date.length > 0) { var Year = date.substring(0, 4); var Month = date.substring(5, 7); var Day = date.substring(8, 10); var NewDate = Month + "/" + Day + "/" + Year; $("#DEROS").val(NewDate); };

btroop202 commented 6 years ago

Is there a way to update data before the submit happens?? It looks like once the function StratusFormsSubmit is called the next time I can do anything is after the data has been sent to the server.

mrackley commented 6 years ago

Sounds like you are fighting a timezone issue maybe? I freaking hate JavaScript dates. Is your server/tenant in a different timezone than you? that could be what you are seeing here?

btroop202 commented 6 years ago

The server may be 1 hour ahead, but not one day behind, I only need a date, not time.

btroop202 commented 6 years ago

So the date is correct in the JSON, but not in the SP list field, on every save it minus one from the date. SO if I select 1 June it is fine in the SratusFormsData JSON, but the SP col has 31 May....WTF over???

warwickbuilds commented 6 years ago

yeah working with SharePoint date is a bit annoying, though there is plenty of good post out their explaining how it all works, the SP database data is stored in UTC, you need to query to site's timezone and convert it to what it was when input. The stratusforms json is the straight text from input. https://julieturner.net/2017/04/sharepoint-time-is-not-your-time-is-not-their-time/

btroop202 commented 6 years ago

I will look into that, but I may try building a workflow to take care of this issue.

warwickbuilds commented 6 years ago

Yes workflow will handle the dates fine. Be careful with modifying list data with a workflow, as StratusForms only reads from it's JSON save and won't detect if a list column has been updated by other means.

btroop202 commented 6 years ago

I found another issue, if I delete the value from the form the SP list is not empty. Is there a trick to delete a date field?