0

I have a problem, because I want to accomplish a task before you delete an item from my list. For this I created a button "Delete client" that runs a workflow or run a javascript. But we have failed because the user can click the "Delete item" that is SharePoint, so I want to hide / block / remove the button "Delete item" of all forms.

enter image description here

BUT, I can not get permission to delete from the list because it will delete the item but executes code before deleting.

| improve this question | | | | |
1

FOR ON-PREMISES

You have to create a farm solution with HideCustomAction element or you can event create you own custom action with your own implementation. Here is a blog post, or another sample about hiding custom actions.

To use this method you have to know your location ID. They are documented in this MSDN article.

To hide a delete button in List you should use

Location = CommandUI.Ribbon

Control ID = Ribbon.ListForm.Display.Manage.DeleteItem

FOR OFFICE 365

You are using Office 365 environment so you cannot use farm solutions. In this case you should use CSOM (with PowerShell or JavaScript) to register a UserCustomAction on your list. Here is sample how to do this with PowerShell (with JS it is very similar). In your case you have to use this CommandUIExtention property:

 <CommandUIExtension> 
     <CommandUIDefinitions> 
         <CommandUIDefinition Location='Ribbon.ListForm.Display.Manage.DeleteItem' /> 
     </CommandUIDefinitions>
 </CommandUIExtension>" 

Hope this helps

| improve this answer | | | | |
  • He is using Office 365. Creating a farm solution is not a good answer to the question. – Akhoy Jul 16 '15 at 5:20
  • Congratulations on your answer, I bet you contains certification in SharePoint as I am doing: p. Thanks for your help. – Renanfdo Jul 17 '15 at 23:42
4

You can add these lines of CSS using a content editor webpart to hide the delete button.

/* For Dispform.aspx */
a[id="Ribbon.ListForm.Display.Manage.DeleteItem-Medium"]
{
display:none;
}


/* For Editform.aspx */
a[id="Ribbon.ListForm.Edit.Actions.DeleteItem-Large"]
{
display:none;
}
| improve this answer | | | | |
  • His case works in special forms where I put this code. If you create new form or a private form this will not work and will need again to make the adjustment, and in the case of private form will not function. Congratulations on your help in cases of specific forms. – Renanfdo Jul 17 '15 at 23:37
  • great CCS and works great but shame it has to be implemented on every form if wanting to hide the delete button :) yes there are permission rules but when you delete the EDIT option then the WF won't trigger as the edit right is required .. – Bucki Sep 22 '17 at 6:41
2

You can have a custom permission level without delete permission. Assign the users/groups of this list this new permission level.

Then in the workflow you can use the impersonation step to still allow your workflow to do the delete.

| improve this answer | | | | |
  • Thanks for your help, but as I mentioned I can not filter by permission because I'm making a script that does not use as another user or use key script creator. But your idea works in cases of workflows. Congratulations – Renanfdo Jul 17 '15 at 23:35
  • Not sure what you mean, but you're welcome. Just wanted to add that it is possible to use a script to trigger a workflow. So you can combine custom JS with the power of workflows. – Jan Jouke Tjalsma Jul 18 '15 at 8:35
0

Thanks to Robert Lindgren's post I got mine working (for a custom edit infopath form - 2010) by using

/* For edit form:  Issue/editifs.aspx */
a[id="Ribbon.Tabs.InfoPathListTab.Actions.Controls.btnDelete-Large"]
{
display:none;
}

and

/* For view form: - Issue/displayifs.aspx  */
a[id="Ribbon.Tabs.InfoPathListDisplayTab.Manage.Controls.btnDelete-Medium"]
{
display:none;
}

It obviously depends on your SharePoint's template implementation. I had to look it up in the dev tools of the browser to see what the ID on the href for the delete button was.

I had to enable "Alternate CSS URL" in "Site Master Page Settings" to have a CSS file I could use (to "Specify a CSS file to be used by this publishing site and all sites") as I don't have full access to the servers (only site collection administrator to my SharePoint site within the organisation). I think I had to enable "SharePoint Server Publishing" in the "Manage site features" to get "Site Master Page Settings".

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.