1

I have a list called Tenders. I need to make sure that when Tender status field is set to "open" no one can delete it. Ideally would be if I won't see options in ecb and ribbon. It is not connected to users permissions but with state of list item. Should I use jQuery or is there an easier way?

4 Answers 4

-1

Could you check this post for some help? - http://pholpar.wordpress.com/2011/10/16/disabling-item-deletion-at-the-sharepoint-user-interface/

0

You could create an Event Receiver for the OnDeleting event that prevents the item from being deleted. Basically have the event receiver check for the value of the field and cancel deletion if the right requirements are not met.

2
  • ItemDeleting is the name of the event receiver: msdn.microsoft.com/en-us/library/… Commented Dec 9, 2011 at 17:53
  • Yes, I know but it is the server side, but how to prevent it on the client side. Simply hide the buttons. I have an idea to work with live() function in jquery and checking the values of current row - status is there, but that is quite tricky. Commented Dec 9, 2011 at 19:53
0

It would be much better UX IMO to prevent the delete by either removing all the delete buttons or disabling them. Telling the user that they can't delete something after a post back is generally considered annoying these days.

Using client side script means that your user can always hack the page, of course, and delete the item anyway. It all comes down to your business requirements.

0

A very much easier approach is to use a conditional show/hide action on Delete button on the JSON of the view:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json",
  "commandBarProps": {
    "commands": [
      {
        "key": "delete",
        "hide": "=if([$Tenders]=='open',true,false)"
      }
    ]
  }
}

Best reggards,

Juan.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.