0

I want to assign the OOTB "Share" functionality of SharePoint 2013 to a custom button. How to achieve it.

0

The OOB share button just pops open a dialog to the appropriate page. So just hit that share button and figure out which page it's opening (aclinv.aspx with some query string options), and hook up a dialog.

<input type="button" onclick="OpenShareDialog()" value="share" />
<script type="text/javascript">

function OpenShareDialog() {
    var options =
     {
         url: _spPageContextInfo.webServerRelativeUrl + "/_layouts/15/aclinv.aspx?forSharing=1&mbypass=1&IsDlg=1",
         dialogReturnValueCallback: Function.createDelegate(null, dialogClosedCallback)    
     };
     SP.UI.ModalDialog.showModalDialog(options);    
}

function dialogClosedCallback(result, target) {
  }

</script>
  • Hi Derek, its not working. DO I need to change anything in querystring? – SPDev Jan 22 '14 at 7:02
  • How are you deploying the code? Are you getting errors? – Derek Gusoff Jan 22 '14 at 14:07
0

put this in Your onclick function for this button



    EnsureScriptFunc('sharing.js', 'DisplaySharingDialog', function(){DisplaySharingDialog('\u002f')});

this will be the same as hitting OOB share button which is in the upper right corner of the page.

best to paste this line in console of browser dev tools (F12) and check if works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.