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
output this.context.listView.folderInfo.folderPath e.g. onExecute
public async onExecute(event: IListViewCommandSetExecuteEventParameters) { console.log(this.context.listView.folderInfo) .... }
Observe that it is undefined.
Note: When you navigate to the subfolder within the document library the folderInfo property is not undefined and contains the folderPath property.
Expected behavior
this.context.listView.folderInfo should contain the folderPath property even when you load the folder directly in the browser.
This is important e.g. in Teams when you use the files tab and click on "Open in SharePoint".
It will directly open a subfolder which contains the files of the current channel. In this case folderInfo is set to undefined and cannot be used.
The text was updated successfully, but these errors were encountered:
var url = id != null ? id : rootFolder;
if (url === undefined) {
// in case of root folder
url = this.context.pageContext.list.serverRelativeUrl;
}
return decodeURIComponent(url);
}
private getQueryStringParameter(paramToRetrieve: string) {
if (document.URL.indexOf("?") == -1)
return null;
var params = document.URL.split("?")[1].split("&");
var strParams = "";
for (var i = 0; i < params.length; i = i + 1) {
var singleParam = params[i].split("=");
if (singleParam[0].toLowerCase() == paramToRetrieve.toLowerCase())
return singleParam[1];
}
}
public async onExecute(event: IListViewCommandSetExecuteEventParameters): Promise {
switch (event.itemId) {
case 'cmd_NewButton':
{
let folderServerRelativeUrl = this.context.listView.folderInfo.folderPath || "";
if (folderServerRelativeUrl === "") {
let folderServerRelativeUrlFromURLQuery =this.getFolderUrlFromQueryString();
if (folderServerRelativeUrlFromURLQuery === "") {
alert("something went wrong, please refresh the page try again.");
break;
} else {
folderServerRelativeUrl = folderServerRelativeUrlFromURLQuery;
}
}
....
break;
}
}
Target SharePoint environment
SharePoint Online
What SharePoint development model, framework, SDK or API is this about?
💥 SharePoint Framework
Developer environment
Windows
What browser(s) / client(s) have you tested
Additional environment details
i have tried it with 2 versions
AND
Describe the bug / error
this.context.listView.folderInfo is undefined when the folder is loaded directly.
Steps to reproduce
1.Create a List Command Set Extension
2.Deploy
Open a document library folder directly e.g
https://yourdomain.sharepoint.com/sites/spfx-test/Shared%20Documents/Forms/AllItems.aspx?id=%2Fsites%2Fspfx-test%2FShared%20Documents%2FSubFolder
output this.context.listView.folderInfo.folderPath e.g. onExecute
public async onExecute(event: IListViewCommandSetExecuteEventParameters) { console.log(this.context.listView.folderInfo) .... }
Note: When you navigate to the subfolder within the document library the folderInfo property is not undefined and contains the folderPath property.
Expected behavior
this.context.listView.folderInfo should contain the folderPath property even when you load the folder directly in the browser.
This is important e.g. in Teams when you use the files tab and click on "Open in SharePoint".
It will directly open a subfolder which contains the files of the current channel. In this case folderInfo is set to undefined and cannot be used.
The text was updated successfully, but these errors were encountered: