You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Feature #3861: adding capability to return a folder as list item (#4151)
* Fixes#3861: added as ListItem return type for folder objects if fetching by specific folders
* Fixed code to retrieve folder as listitem
---------
Co-authored-by: Gautam Sheth <gautam.sheth@staffbase.com>
Returns the folders inside the root folder of the list called 'Shared Documents'. Please use Get-PnPFolder -ListRootFolder <folder> | Get-PnPFolderInFolder instead.
Returns the folder called 'Test' which is located in the root of the site collection located at '/sites/demo' inside 'Shared Documents' document library as a SharePoint list item.
DefaultRetrievalExpressions=newExpression<Func<Folder,object>>[]{ f =>f.ServerRelativeUrl, f =>f.Name, f =>f.TimeLastModified, f =>f.ItemCount};
38
42
39
43
Folderfolder=null;
40
-
switch(ParameterSetName)
44
+
switch(ParameterSetName)
41
45
{
42
46
caseParameterSet_FOLDERSINCURRENTWEB:
43
-
{
44
-
WriteVerbose("Getting all folders in the root of the current web");
45
-
ClientContext.Load(CurrentWeb, w =>w.Folders.IncludeWithDefaultProperties(RetrievalExpressions));
46
-
ClientContext.ExecuteQueryRetry();
47
-
WriteObject(CurrentWeb.Folders,true);
48
-
break;
49
-
}
47
+
{
48
+
WriteVerbose("Getting all folders in the root of the current web");
49
+
ClientContext.Load(CurrentWeb, w =>w.Folders.IncludeWithDefaultProperties(RetrievalExpressions));
50
+
ClientContext.ExecuteQueryRetry();
51
+
WriteObject(CurrentWeb.Folders,true);
52
+
break;
53
+
}
50
54
51
55
caseParameterSet_CURRENTWEBROOTFOLDER:
52
-
{
53
-
WriteVerbose("Getting root folder of the current web");
54
-
folder=CurrentWeb.RootFolder;
55
-
56
-
ReturnFolderProperties(folder);
57
-
break;
58
-
}
56
+
{
57
+
WriteVerbose("Getting root folder of the current web");
58
+
folder=CurrentWeb.RootFolder;
59
+
60
+
ReturnFolderProperties(folder);
61
+
break;
62
+
}
59
63
60
64
caseParameterSet_LISTROOTFOLDER:
61
-
{
62
-
WriteVerbose("Getting root folder of the provided list");
63
-
varlist=ListRootFolder.GetList(CurrentWeb);
64
-
folder=list.RootFolder;
65
-
66
-
ReturnFolderProperties(folder);
67
-
break;
68
-
}
65
+
{
66
+
WriteVerbose("Getting root folder of the provided list");
67
+
varlist=ListRootFolder.GetList(CurrentWeb);
68
+
folder=list.RootFolder;
69
+
70
+
ReturnFolderProperties(folder);
71
+
break;
72
+
}
69
73
70
74
caseParameterSet_FOLDERSINLIST:
71
-
{
72
-
// Gets the provided list
75
+
{
76
+
// Gets the provided list
73
77
#pragma warning disable CS0618// Type or member is obsolete
74
-
varlist=List.GetList(CurrentWeb);
78
+
varlist=List.GetList(CurrentWeb);
75
79
#pragma warning restore CS0618// Type or member is obsolete
76
80
77
-
// Query for all folders in the list
78
-
CamlQueryquery=CamlQuery.CreateAllFoldersQuery();
79
-
do
80
-
{
81
-
// Execute the query. It will retrieve all properties of the folders. Refraining to using the RetrievalExpressions would cause a tremendous increased load on SharePoint as it would have to execute a query per list item which would be less efficient, especially on lists with many folders, than just getting all properties directly
// Execute the query. It will retrieve all properties of the folders. Refraining to using the RetrievalExpressions would cause a tremendous increased load on SharePoint as it would have to execute a query per list item which would be less efficient, especially on lists with many folders, than just getting all properties directly
0 commit comments