SharePoint / sp-dev-docs

SharePoint & Viva Connections Developer Documentation
https://docs.microsoft.com/en-us/sharepoint/dev/
Creative Commons Attribution 4.0 International
1.25k stars 1.01k forks source link

DatesInUtc parameter of RenderListDataAsStream not working #9916

Closed gabbsmo closed 2 months ago

gabbsmo commented 2 months ago

Target SharePoint environment

SharePoint Online

What SharePoint development model, framework, SDK or API is this about?

SharePoint CSOM

Developer environment

Windows

What browser(s) / client(s) have you tested

Additional environment details

No response

Describe the bug / error

The RenderListDataAsStream API has a parameter DatesInUtc. When it is true, it indicates that any DateTime values in the Caml query is in universal time. However, since today or earlier, it no longer seem to work. For the same query, I need to set the site's time zone to UTC to get any results.

Steps to reproduce

  1. Set time zone in regional settings to Stockholm
  2. Create a file with the value 2024-07-07 for the field TestDate
  3. Call RenderListDataAsStream with the following parameters and CAML query:
RenderListDataParameters
{
    ViewXml = viewXml,
    DatesInUtc = true,
    RenderOptions = RenderListDataOptions.ListData,
    RenderURLFieldInJSON = true
}
<View Scope='Recursive'>
    <Query>
        <Where>
            <Eq>
                <FieldRef Name='TestDate' />
                <Value IncludeTimeValue='TRUE' Type='DateTime'>2024-07-06T22:00:00Z</Value>
            </Eq>
        </Where>
        <OrderBy UseIndexForOrderBy='FALSE' Override='FALSE'>
            <FieldRef Name='Modified' Ascending='False' />
        </OrderBy>
    </Query>
    <ViewFields>
        <FieldRef Name='ContentTypeId' />
        <FieldRef Name='Modified' />
        <FieldRef Name='FileLeafRef' />
        <FieldRef Name='File_x0020_Type' />
        <FieldRef Name='Title' />
        <FieldRef Name='TestChoice' />
        <FieldRef Name='TestNumber' />
        <FieldRef Name='TestDate' />
        <FieldRef Name='TestMmd' />
        <FieldRef Name='TestMmdMulti' />
        <FieldRef Name='TestPeopleMultiple' />
        <FieldRef Name='TestNote' />
        <FieldRef Name='TestBoolean' />
        <FieldRef Name='Editor' />
        <FieldRef Name='FileDirRef' />
        <FieldRef Name='File_x0020_Size' />
        <FieldRef Name='CheckoutUser' />
        <FieldRef Name='CheckedOutUserId' />
        <FieldRef Name='ContentType' />
        <FieldRef Name='ContentTypeId' />
        <FieldRef Name='Editor' />
        <FieldRef Name='File_x0020_Size' />
        <FieldRef Name='File_x0020_Type' />
        <FieldRef Name='FileRef' />
        <FieldRef Name='FileLeafRef' />
        <FieldRef Name='HTML_x0020_File_x0020_Type' />
        <FieldRef Name='Modified' />
        <FieldRef Name='_UIVersionString' />
        <FieldRef Name='_CheckinComment' />
    </ViewFields>
    <RowLimit Paged='TRUE'>50</RowLimit>
</View>
  1. Notice there are no results
  2. Change time zone to UTC
  3. Try again
  4. Notice that there are results

Expected behavior

When using the DatesInUtc parameter, passing DateTime values in UTC, and there are matching items I expect them in the result, regardless of regional settings.

gabbsmo commented 2 months ago

Adding the attribute StorageTZ='TRUE' to date values seem to help. I could swear this was not necessary before.

Working example: <Value StorageTZ='TRUE' IncludeTimeValue='TRUE' Type='DateTime'>2024-07-06T22:00:00Z</Value>