0

For the following folder structure, let's say I am viewing documents under "Level 2 Folder", I would like to get ID for "Level 2 Folder" using JavaScript, either using JSCOM or Rest API for SharePoint Online.

-Level 1 Folder
--Level 2 Folder
---Level 3 Document

3 Answers 3

2

Try the below REST API endpoint to get the Folder Item ID,

_spPageContextInfo.webAbsoluteUrl + "/_api/web/GetFolderByServerRelativeUrl('" + ctx.rootFolder + "')/listitemallfields/id"

Example:

http://sharepointsite/_api/web/GetFolderByServerRelativeUrl('/Library/Level 1 Folder/Level 2 Folder')/listitemallfields/id
1
  • This worked though my answer seems to be simpler but I am not sure how reliable it is.
    – Afroz
    Commented May 18, 2016 at 2:35
0

Use the below url for REST call

var restUrl = _spPageContextInfo.webAbsoluteUrl + "/_api/web/GetFolderByServerRelativeUrl('" + ctx.rootFolder + "'/UniqueId"
1
  • This gets me the UniqueID which is a GUID but not the List Item ID which is a integer. I need the integer List Item ID
    – Afroz
    Commented May 18, 2016 at 1:10
0

This turned out to be very simple.

ctx.ListData.FolderId

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.