Skip to content

command spo folder roleinheritance break and reset does not work with rootfolder or site relative of folder #3823

@reshmee011

Description

@reshmee011

Description

Command spo folder roleinheritance break and spo folder roleinheritance reset throw an error when root folder of a library or preceding slash is present in the folderUrl parameter.

Aim :

  1. Add flexibility to pass preceding slash in the parameter value folderUrl without any errors
    e.g.
    m365 spo folder roleinheritance reset --webUrl "https://contoso.sharepoint.com/sites/Test_Site" --folderUrl "/Shared Documents/FolderPermission"

  2. Allow the root folder url of a library to be passed as parameter value folderUrl
    e.g. m365 spo folder roleinheritance break --webUrl "https://contoso.sharepoint.com/sites/Test_Site" --folderUrl "/Shared Documents"

Implementation:

  1. To implement aim 1 , use
    const serverRelativeUrl: string = urlUtil.getServerRelativePath(args.options.webUrl, args.options.folderUrl);

to handle different ways the folderUrl value can be passed, i.e.

  • with preceding slash
  • no preceding slash
  • server relative url
  1. To implement aim 2 to allow root folder to be used , a condition can be added to check whether folderUrl value passed is a root folder and use the appropriate api call

const roleFolderUrl: string = urlUtil.getWebRelativePath(args.options.webUrl, args.options.folderUrl); let requestUrl: string = ${args.options.webUrl}/_api/web/`;

  if (roleFolderUrl.split('/').length === 2) {
    requestUrl += `GetList('${formatting.encodeQueryParameter(serverRelativeUrl)}')`;
  }
  else {
    requestUrl += `GetFolderByServerRelativeUrl('${encodeURIComponent(serverRelativeUrl)}')/ListItemAllFields`;
  }

`

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions