0

There is an extension (custom ribbon) button on top of the list, that is connected to third-party apps, updating the list where you run it.

It's needed to restrict the extension to be used only in the list that is required to use it. I couldn't find it in the configurations while creating the list. Should it be a template?

The main question would be - how to restrict other lists have the button on top of them?

3
  • Is this extension developed by you or is 3rd party solution? If you have the extension code, you might be able to control it from code. Aug 2 at 7:46
  • I developed it using Microsoft's documentation of creating a custom extension with React. Aug 2 at 7:47
  • Check my answer given below & let me know if it helps. Aug 2 at 7:52

1 Answer 1

4

You can get the list name in code using this.context.pageContext.list.title and compare it with your list title as given below:

public onListViewUpdated(event: IListViewCommandSetListViewUpdatedParameters): void {  
    var Libraryurl = this.context.pageContext.list.title;  
     
    const compareOneCommand: Command = this.tryGetCommand('COMMAND_1');  
    if (compareOneCommand) {  
      // This command should be hidden unless exactly one row is selected.  
      compareOneCommand.visible = (event.selectedRows.length === 1 && Libraryurl == "BotFiles" );  
    }  
}  

Source: SPFX Extension Apply List View Command Set to Specific List or Library

4
  • Thank you, seems like a legit solution. The downside of it is that we can't make changes unless we update the extension's code. Can it be done more dynamically or maybe from the settings of Sharepoint Online interface? @Ganesh Sanap Aug 2 at 7:56
  • 2
    Might not be possible from SharePoint UI. But, you can pass the properties to extension programmatically: sharepoint.stackexchange.com/questions/227137/… Aug 2 at 8:34
  • Here's a sample I wrote that does exactly this (uses a comma separated list of lists as a property). This approach allows you to update the properties via PowerShell/REST without having to redeploy. github.com/pnp/sp-dev-fx-extensions/blob/main/samples/… Aug 2 at 15:51
  • Thanks for sharing the sample URL @theChrisKent. Very helpful! Aug 2 at 16:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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