问题
SharePoint Modern: Is it possible to add an custom action using command set for a particular list or how to activate a custom action for specific list? I am trying to develop a custom action for specific list but when I deployed in SharePoint tenant this custom action is added for all list(same type of list template).
回答1:
Here is my test solution to limit command set extension to specific list.
We could get current list title by this.context.pageContext.list.title
.
@override
public onListViewUpdated(event: IListViewCommandSetListViewUpdatedParameters): void {
const compareOneCommand: Command = this.tryGetCommand('COMMAND_1');
if (compareOneCommand) {
// This command should be hidden unless exactly one row is selected.
compareOneCommand.visible = this.context.pageContext.list.title === 'MyList3';
}
}
One similar thread
回答2:
Yes it is.. You can check it with the list id, and if matches make command.visible == true
来源:https://stackoverflow.com/questions/53943139/sharepoint-extension-command-set