Friday, September 23, 2016

String Utility Actions in SPD 2013

Hi Folks,

I'll share my experience how I used different string utility action to implement the requirement.

1. Split the string in date/time field to get the date part

Start Date: 9/22/2016 5:00:00 AM

Here the date/time value is 9/22/2016 5:00:00 AM and I need to get the date part i.e. 9/22/2016. Check the below steps.

Step1: From the string I need to find a character which splits date and time. I could see a space splits it. I used the action "Find Substring in string" and made it to look for space.


Step2:  I used the action "Extract Substring from the start of string" to extract the date part.

The date part got stored in the variable named as "substring1".

Wednesday, September 7, 2016

Hide Aprove/Reject button from the ribbon

Hi Folks,

I got a requirement to hide 'Approve/Reject' button but the ribbon in Display form. I've written a short JavaScript code to achieve the functionality.

1. Use developer tools in Chrome to get the ribbon id.



<a class="ms-cui-ctl-medium" id="Ribbon.ListForm.Display.Manage.ApproveReject-Medium" onclick="return false;" href="javascript:;" mscui:controltype="Button" aria-describedby="Ribbon.ListForm.Display.Manage.ApproveReject_ToolTip" role="button" unselectable="on"><span class="ms-cui-ctl-iconContainer" unselectable="on"><span class=" ms-cui-img-16by16 ms-cui-img-cont-float ms-cui-imageDisabled" unselectable="on"><img class="" style="top: -313px;left: -1px;" unselectable="on" src="/_layouts/15/1033/images/formatmap16x16.png?rev=44"></span></span><span class="ms-cui-ctl-mediumlabel" unselectable="on">Approve/Reject</span></a>



2. Create a custom display form for a list and add the below code.
<script type="text/javascript" src="https://accobrands.sharepoint.com/ITCompliance/SiteAssets/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="https://accobrands.sharepoint.com/ITCompliance/SiteAssets/sputility.min.js"></script>
<script type="text/javascript" src="https://accobrands.sharepoint.com/ITCompliance/SiteAssets/url.js"></script>
<script type="text/javascript">
    function hideEdit() {
        var edit = document.getElementById("Ribbon.ListForm.Display.Manage.ApproveReject-Medium");
        edit.style.display = "none";
    }       
    _spBodyOnLoadFunctionNames.push("hideEdit");
</script>

3. Save the form and see the result by clicking "Preview in browser".