I got this request from Larry:
Good day A, Have a question. Is there an easy way to add to the SP 2010 ribbon an approve all button. I hate having to select each item and manually approve each one. I have found some script but they are deployed on central admin. I would like to a void that.
thanks
It’s not like i didn’t have anything to do, but he bought me a beer…
Here we go
This one uses the Client Object Model in SharePoint 2010 and is therefore usable in SharePoint 2010 only.
The code adds a custom button to the “Ribbon.Document” or “Ribbon.ListItem” that calls a script on the items selected using the in line checkbox.
Get the file “ApproveSelected.js” from here
Get jQuery from here
Put the files in a document library or in a folder created with SharePoint Designer. Ensure all users have read access to the location.
Insert a CEWP in the list view where you want this feature to be activated. Use the “Content Link” option in the “Edit web part” panel of the CEWP to link to the CEWP-code that you have put in a text file in the same location as the “ApproveSelected.js”.
Use this code:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> <script type="text/javascript" src="/test/Scripts/ApproveSelected/ApproveSelected.js"></script> <script type="text/javascript"> var tabBtn = { "btnLabelApprove":"Approve selected", "btnLabelReject":"Reject selected", "groupLabel":"Approve or reject" }; var workingOnItNotification = 'Processing items...'; var doneNotification = '{0} items processed'; </script>
Change the path to the file “ApproveSelected.js” to match your local copy. If you prefer to use a local copy of jQuery, change that path to.
You may also change the variables if you want another text in the button or the notification messages.
It should look like this in the list view
NOTE
The button will disappear if the screen width is to narrow. The built in ribbon buttons will “shrink” to fit a narrow screen – this one will not.
Extras
This code uses a new “hack” to overcome the missing “list toolbar” when adding another webpart to the page. I’ll do a separate little article on that one.
Enjoy!
Alexander