none
Adding a Approve/Reject Button for List Items RRS feed

  • Question

  • Hello,

    I need to add an Approve/Reject button for each list item. It's not intuitive for the user to go into the edit settings to approve each list item and time consuming as well. Thanks for the help!

    Michael Williams 


    SharePoint Engineer - Mike

    Monday, April 24, 2017 12:48 PM

Answers

  • Hi,

    We can use jQuery to achieve it, add the code below into a script editor web part into list view page.

    <script src="//code.jquery.com/jquery-3.1.0.min.js" type="text/javascript"></script>
    <script type="text/javascript">
    $(function () {
    	var listID=$(".ms-listviewtable").attr("id").split('-{')[0];
    	$(".ms-listviewtable>tbody>tr").append("<input style='background:#00ff00' name='customApproveBtn' type='button' value='Approve/Reject'/>");
    	$("input[name='customApproveBtn']").click(function(){
    		var itemId=$(this).parent().attr("id").split(',')[1];
    		var pageUrl=_spPageContextInfo.webAbsoluteUrl+"/_layouts/15/approve.aspx?List="+listID+"&ID="+itemId+"&IsDlg=1"
    		showSPDialog(pageUrl);
    	});
    });
    function showSPDialog(pageUrl) {
        var options = { url: pageUrl,autoSize:true};
        SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);
    }
    </script>
    

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Thursday, April 27, 2017 1:43 PM
    Moderator

All replies

  • Hi Michael,

    SharePoint provide the "Approve/Reject" button in call out menu for each list items.

    If it not meet you, please provide more information about your requirement.

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Thursday, April 27, 2017 8:06 AM
    Moderator
  • The customer might not see this as being able to click 3 dots as being intuitive or obvious to them. I was thinking of having a green button that says something like "approve/reject".

    SharePoint Engineer - Mike

    Thursday, April 27, 2017 12:35 PM
  • Hi,

    We can use jQuery to achieve it, add the code below into a script editor web part into list view page.

    <script src="//code.jquery.com/jquery-3.1.0.min.js" type="text/javascript"></script>
    <script type="text/javascript">
    $(function () {
    	var listID=$(".ms-listviewtable").attr("id").split('-{')[0];
    	$(".ms-listviewtable>tbody>tr").append("<input style='background:#00ff00' name='customApproveBtn' type='button' value='Approve/Reject'/>");
    	$("input[name='customApproveBtn']").click(function(){
    		var itemId=$(this).parent().attr("id").split(',')[1];
    		var pageUrl=_spPageContextInfo.webAbsoluteUrl+"/_layouts/15/approve.aspx?List="+listID+"&ID="+itemId+"&IsDlg=1"
    		showSPDialog(pageUrl);
    	});
    });
    function showSPDialog(pageUrl) {
        var options = { url: pageUrl,autoSize:true};
        SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);
    }
    </script>
    

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Thursday, April 27, 2017 1:43 PM
    Moderator
  • Hi Mike

    You can try a post I have written a while back.

    https://reshmeeauckloo.wordpress.com/2015/12/17/sharepoint-approve-selected-list-items/

    When “Set Approve” is clicked after selected some items, the status changes to “Approve”. 

    You can amend the code to add a reject button as well.

    Regards

    Reshmee

    Thursday, April 27, 2017 2:38 PM