Delete item button

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Posts: 23
Joined: Fri Jan 26, 2018

03 Aug 2018


I want to add a button to delete the item. I don't want to use the button in the toolbar.

Is it possible to achieved this?


User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

06 Aug 2018

Dear cmagnan,
Please, use the following code in an OnClick property of a button:

Code: Select all

$( "a[aria-describedby='Ribbon.ListForm.Edit.Actions.DeleteItem_ToolTip']" )[0].click();
This will click the button in the Ribbon for you, essentially having the same effect as the Ribbon button.
DeleteItemButton.png (38.44 KiB) Viewed 55035 times

Posts: 2
Joined: Sat Jan 22, 2022

22 Jan 2022

Does this code still work? I am using Sharepoint forms classic and it gives an error from Developer tools. Uncaught Type Error: Cannot read properties of undefined (reading 'click')

User avatar
Posts: 264
Joined: Wed Jun 05, 2019

31 Jan 2022

Hello picoso1986,

What SharePoint version are you using? Online or On-premises?

Posts: 2
Joined: Sat Jan 22, 2022

31 Jan 2022

Nikita has recommended a solution for this. I am using SharePoint On Prem 2016. The problem is that the customer wanted to disable the delete button by permissions so this affects the code on the button. He recommended to me the following:

"This code simply clicks the delete button, nothing else, it wouldn't work if the button is disabled. You have three options here:

1) Enable the Delete button, but hide it with CSS. Users still won't see the button, but you can run this script with no problem.

2) Write a custom JSOM or REST request to SharePoint, to find and delete item by ID. This will be harder, but should still be possible.

3) Add a field, maybe Yes/No field, something like MarkedToDelete. You can hide this field, and set the value with a script. Then, run a workflow on item update, and if MarkedToDelete is true, then delete the item. This requires extra steps, so it's not recommended, but possible. "

I posted here for anyone else running into this problem.

Thank you Margarita!

  • Information
  • Who is online

    Users browsing this forum: No registered users and 3 guests