Open aalkousheh opened 2 months ago
I found workaround for this as below.
`private getFolderUrlFromQueryString(): string { const id = this.getQueryStringParameter("Id"); const rootFolder = this.getQueryStringParameter("RootFolder");
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
`
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) .... }
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.