Friday, 18 August 2017

Retrieving Access Request Email from SharePoint Site

The access request feature allows users to request access to site that they do not currently have permission to see. As a site owner, you can configure the feature to send you mail when someone requests access to a site for approval.

use the below code find out the  Access request owner using below JSOM code  


function getAccessRequestOwner() {
    var clientContext = SP.ClientContext.get_current();
    this.oWeb = clientContext.get_web();
    clientContext.load(this.oWeb, 'RequestAccessEmail');

    clientContext.executeQueryAsync(
        Function.createDelegate(this, this.onQuerySucceeded),
        Function.createDelegate(this, this.onQueryFailed)
    );
}

function onQuerySucceeded(sender, args) {
    console.log('RequestAccessEmail: ' + this.oWeb.get_requestAccessEmail());
}
   
function onQueryFailed(sender, args) {
    alert('Request failed. ' + args.get_message() +
        '\n' + args.get_stackTrace());
}


//Call function
getAccessRequestOwner();