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