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 = {btnLabel:'Approve selected',groupLabel:'Approve'};
var approvingItemsNotification = 'Approving files...';
var approvingItemsDoneNotification = '{0} items approved';
</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


January 12, 2012 at 3:42 am |
You rock! I owe you another beer. You can count on by pay day! Thanks A
January 26, 2012 at 6:00 pm
Hi,
Glad you liked it
Alexander
January 13, 2012 at 10:12 pm |
To check in multiple documents at once I use Harmon.ie ‘s ‘addin’ to Outlook. It allows you to select more than one document and check them in all from within Outlook. Very handy.
January 20, 2012 at 4:32 pm |
Neat solution! Could you use the same basic script to trigger a workflow on all selected items?
January 26, 2012 at 6:02 pm
Hi,
Yes, if the workflow is set to trigger on change you could modify this script to set the “trigger field” to the appropriate value.
Alexander
January 31, 2012 at 7:55 pm |
Hi Alex,
Thanks for the code. Is it possible to use this code for any other field?
I have dropdown field with values Save as Draft, Submit, Approved and Rejected. So is it possible to change the dropdown value from Submit to Approved using ribbon button?
Thanks in advance
February 9, 2012 at 11:43 pm
Hi,
Yes this should be possible. You must change the function “checkAndUpdate” to achieve this. Look at the field “_ModerationStatus” – this is the one you should change for your “dropdown field”.
Alexander
February 13, 2012 at 4:33 pm |
Awesome solution, thanks Alexander!!!! Now I don’t have to go into datasheet view anymore to approve multiple items!!!!
Colin
February 13, 2012 at 4:36 pm
Glad you liked it
Alexander