Guest User

Untitled

a guest
Jun 19th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. @override
  2. public onListViewUpdated(event: IListViewCommandSetListViewUpdatedParameters): void {
  3. const duplicateCommand: Command = this.tryGetCommand('DUPLICATE_ITEM');
  4. if (duplicateCommand) {
  5. duplicateCommand.visible = (event.selectedRows.length === 1);
  6. }
  7. }
  8.  
  9. @override
  10. public onExecute(event: IListViewCommandSetExecuteEventParameters): void {
  11. switch (event.itemId) {
  12. case 'DUPLICATE_ITEM': this.DuplicateItem(event); break;
  13. default: throw new Error('Unknown command');
  14. }
  15. }
  16. private DuplicateItem(event: IListViewCommandSetExecuteEventParameters): void {
  17. //stuff to do
  18. pnp.sp.web.lists.getByTitle(listName).items.add(data)
  19. .then((result: any) => {
  20. //refresh ListView to show new item
  21. }).catch(error => {
  22. //error handling
  23. });
  24. }
Add Comment
Please, Sign In to add comment