Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @override
- public onListViewUpdated(event: IListViewCommandSetListViewUpdatedParameters): void {
- const duplicateCommand: Command = this.tryGetCommand('DUPLICATE_ITEM');
- if (duplicateCommand) {
- duplicateCommand.visible = (event.selectedRows.length === 1);
- }
- }
- @override
- public onExecute(event: IListViewCommandSetExecuteEventParameters): void {
- switch (event.itemId) {
- case 'DUPLICATE_ITEM': this.DuplicateItem(event); break;
- default: throw new Error('Unknown command');
- }
- }
- private DuplicateItem(event: IListViewCommandSetExecuteEventParameters): void {
- //stuff to do
- pnp.sp.web.lists.getByTitle(listName).items.add(data)
- .then((result: any) => {
- //refresh ListView to show new item
- }).catch(error => {
- //error handling
- });
- }
Add Comment
Please, Sign In to add comment