Share Point "vti_x005f_timelastwritten" Filter based on date property

Dhruvin Moradiya 55 Reputation points
2023-03-14T04:53:44.8966667+00:00

I want to filter files based on the vti_x005f_timelastwritten Property. This property can be found under Items/Properties.

https://domain.sharepoint.com/sites/{siteName}/_api/web/GetFolderByServerRelativeUrl('/sites/{siteName}/Shared Documents/Folder')/Files?$expand=ListItemAllFields,Properties&$filter=vti_x005f_timelastwritten gt datetime'2023-03-05T12:40:00'

This query is not working. I was expecting a file with its content updated. The vti_x005f_timelastwritten field keeps the date the file's content was updated.

error:


{

"odata.error": {

    "code": "-1, Microsoft.SharePoint.Client.InvalidClientQueryException",

    "message": {

        "lang": "en-US",

        "value": "Field or property \"vti_x005f_timelastwritten\" does not exist."

    }

}
}

When I try the below method


$filter=Properties/vti_x005f_timelastwritten gt datetime'2023-03-05T12:40:00Z

I got this error


{

"odata.error": { 

    "code": "-2146233086, System.ArgumentOutOfRangeException",

    "message": { 

        "lang": "en-US", 

        "value": "Specified argument was out of the range of valid values.\r\nParameter name: fieldName" 

    } 

} 
}

Any Idea how to modify the query to get the expected output?

SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,657 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 30,751 Reputation points Microsoft Vendor
    2023-03-14T07:49:14.4266667+00:00

    Hi @Dhruvin Moradiya

    Per my test, I can get the same error Field or property \"vti_x005f_timelastwritten\" does not exist. with yours. After search the document, there is no such properties in sharepoint currently. You can refer to the document

    https://learn.microsoft.com/en-us/previous-versions/office/sharepoint-csom/ee542189(v=office.15)

    As a workaround, I would recommend you to use TimeLastModified properties like following url.

    mysharepointsiteurl/_api/web/GetFolderByServerRelativeUrl('/relativesiteurl/Documents')/Files?$filter=TimeLastModified gt datetime'2023-03-05T12:40:00'
    
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.