Monday, May 18, 2015

Approve or reject list items

I have previously posted a JavaScript solution for approving multiple documents or list items. This is an updated version that adds two buttons in the ribbon: one for “Approve” and one for “Reject”. Refer the original solution for details, but please note that the variables for controlling the text values have changed.

Use this code to load the solution in a list view
<script type="text/javascript" src="http://ift.tt/1LdO4RA"></script>
<script type="text/javascript" src="/Scripts/ApproveOrRejectSelected.js"></script>
Change the default text values

If you are happy with the default, English text, you can skip this next step.

To override the default text, add this to the CEWP below the script reference to “ApproveOrRejectSelected.js”,and change the text as you like:

<script type="text/javascript">
spjs.contentApproval.text = {
        "approveBtn":"Approve selected",
        "rejectBtn":"Reject selected",
        "groupLabel":"Approve or Reject",
        "working":"Processing items...",
        "done":"{0} items processed"
};
</script>

You can wrap it like this to switch based on the logged in users language (in MUI environments):

switch(_spPageContextInfo.currentLanguage){
        case 1044:
                // Add Norwegian values
                spjs.contentApproval.text = {
                        "approveBtn":"Approve selected",
                        "rejectBtn":"Reject selected",
                        "groupLabel":"Approve or Reject",
                        "working":"Processing items...",
                        "done":"{0} items processed"
                };
        break;
        case 1031:
                // Add German values
                spjs.contentApproval.text = {
                        "approveBtn":"Approve selected",
                        "rejectBtn":"Reject selected",
                        "groupLabel":"Approve or Reject",
                        "working":"Processing items...",
                        "done":"{0} items processed"
                };
        break;
}
Download ApproveOrRejectSelected.js

Get the file here.

Alexander


by Alexander Bautz via SharePoint JavaScripts

No comments:

Post a Comment