I stumbled across a requirement where I had to change the RequestAccessMail via clientside code. This property is not available via CSOM or JSOM. Feature Request

There are several people who asked if this is possible and i havent found an answer that didnt say "no".

Well there is an option. When you are willing to go a quite hacky way, you can do pretty much anything that is possible via the UI when simply emulating UI interaction via JS.

Here's my example for the RequestAccessMail:

//quite dirty hack but at this point the only possibility to set the AccessRequest mail via clientside
function setAccessRequest(mail) {
    var iframe = document.createElement('iframe');
    //set the setrqacc.aspx link
    var setrqaccUrl = _spPageContextInfo.webAbsoluteUrl + '/_layouts/15/setrqacc.aspx?type=web';
    //create setrqacc.aspx hidden iframe
    iframe.setAttribute('src', setrqaccUrl);
    iframe.setAttribute('style', 'display:none');
    iframe.onload = function () {
        //this will fire 2 times - the first time when its initially loaded. the second after the changes were applied (page is reloaded (postback) after the submitbutton is triggered)
        var $iframeInput = $('input[id*="_txtEmail"]', $(iframe).contents());
        if ($iframeInput.length) {
            //initial load - apply settings
            //gets iframeInput's parent so the current input can be placed inside
            var $iframeBtn = $('input[id*="_btnSubmit"]', $(iframe).contents());
            //trigger the post
        } else {
            //second load - do callback

(Of course the code is wrapped in some warnings to prevent prematurely abortion of the running code)

This is due to the multiple asynch pageloads quite slow, but works fine.

Now here's my question - and yes I know there is no clear answer - Why not doing this for every missing feature in CSOM and JSOM (and every wanted feature that is possible via the UI)?

  • You have essentially created an app but without using the app infrastructure – Eric Alexander Mar 25 '15 at 17:17
  • @PirateEric It's working via an iframe too yes, but even with the app infrastructure my example would not have been possible. The only other way is a SSOM webservice that handles the changes on the property (or some other serverside component). – Mx. Mar 26 '15 at 12:41

Your Answer

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

Browse other questions tagged or ask your own question.