New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ValidateUpdateItem Date Time FieldValue formats #4917
Comments
Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible. |
It will be very helpful if ISO formatted date times were supported. |
"yyyy-MM-dd hh:mm:ss" |
It will be very helpful if ISO formatted date times were supported. |
If you want to easily get the supported value from a Date:
Don't forget to take timezone into account:
|
Thanks @EagleWizard28, that worked for me irrespective of Regional settings. |
According to the SharePoint Online OData CSDL, the actions |
|
I'd like to request a bit more information on the AddValidateUpdateItemUsingPath/ValidateUpdateListItem REST endpoints in regards to Date/Time fields.
I know that supplying an ISO formatted string to the
FieldValue
property in the FormValues object will result in an error. It seems you need to know the format that the endpoint will accept.Depending on your locale settings in your SPWeb object, the format may be "DD/MM/YYYY hh:mm" or "MM/DD/YYYY hh:mm AM/PM" and possibly other variations (e.g., the date separator might need to be '-').
Given the information supplied by ClientFormSchema for a date time field, I don't know how to format the value in a reliable generic way that the API will always accept. Just for reference, here's the ClientFormSchema for a date/time field
So I get a
TimeSeparator
property but that's about it in terms of what format the aforementioned APIs will accept. I also get aLocaleId
which could be used in toLocaleString() on a Date object but MDN advises against relying on the output of that method.Furthermore, SharePoint doesn't like the comma this method might place in between the date and time.
The error I get with my SPWeb locale configuration is as follows
And if I change the locale information on my SPWeb object
I know that the Modern UI uses these APIs for creating/updating items so how are the default forms able to work out what date format to put in
FieldValue
for a date time field type?Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
The text was updated successfully, but these errors were encountered: