1

I am working with SharePoint 2013 and trying to remove the following red-framed section of the standard-generated modal window, which pops-up when checking in a document.

enter image description here

I do not own SharePoint Designer and I also don't have access to the top level. I am simply a Site Owner of a subsite.

I guess there is an option to work on this problematic using CSS and the display:none feature, but that would mean I have to move the "Kommentare" (engl. comments) section up with CSS.

enter image description here

So is there maybe any workaround by removing this certain table row?

Probably one also needs jQuery, from what I have researched.

  • disable the checkout in the document library? that would remove it – Ali Jafer Mar 23 '18 at 9:04
  • One should be still able to checkout a document. I just don't want that users have the option, that after checking in a document they still can keep a document checked out (if they for example want to continue editing on it after a short break) – SteffPoint Mar 23 '18 at 9:06
1

If you have Full Control on the site you'll have the permissions to register a scriptlink iirc.

Create a file on your computer, call it HideRetainCheckout.js or something and add the following:

if (!Element.prototype.matches)
    Element.prototype.matches = Element.prototype.msMatchesSelector || 
                                Element.prototype.webkitMatchesSelector;

if (!Element.prototype.closest)
    Element.prototype.closest = function(s) {
        var el = this;
        if (!document.documentElement.contains(el)) return null;
        do {
            if (el.matches(s)) return el;
            el = el.parentElement || el.parentNode;
        } while (el !== null && el.nodeType === 1); 
        return null;
    };

function ready(fn) {
  if (document.attachEvent ? document.readyState === "complete" : document.readyState !== "loading"){
    fn();
  } else {
    document.addEventListener('DOMContentLoaded', fn);
  }
}

if(decodeURIComponent(window.location.href).indexOf("checkin.aspx?List={D3E77CCA-4514-4543-8656-D1AF54941CE9}") > -1) {
    ready( function() {
        document.querySelector("#KeepCheckoutRadioGroupLabel").closest("td.ms-inputformcontrols").parentNode.style.display = "none"
    });
}

Change the part List={D3E77CCA-4514-4543-8656-D1AF54941CE9} to match the listid of your document library. You'll find the id in the URL when you open the list settings.

Upload the file to SiteAssets

To register the script you run the following script one time in the browser console:

SP.SOD.executeFunc("sp.js", "SP.ClientContext", function() {
    var ctx = SP.ClientContext.get_current();
    var web = ctx.get_web();

    var customAction = web.get_userCustomActions().add();
    customAction.set_location('ScriptLink');

    customAction.set_scriptSrc('~site/SiteAssets/HideRetainCheckout.js');
    customAction.set_sequence(9);
    customAction.set_title('HideRetainCheckout');
    customAction.set_description('HideRetainCheckout');
    customAction.update();

    ctx.executeQueryAsync(function() {
         console.log('New Support files added to Site.');
    }, function(s,a) {   
        console.log("Error", a.get_message());
    });
});

Update:

To remove a custom action use the following:

SP.SOD.executeFunc("sp.js", "SP.ClientContext", function() {
        var ctx = SP.ClientContext.get_current();
        var userCustomActions = ctx.get_web().get_userCustomActions();
        ctx.load(userCustomActions);

        ctx.executeQueryAsync(function() { 

            userCustomActions.get_data().forEach(function(action) { 

                if(action.get_title() === "HideRetainCheckout") {
                    action.deleteObject();
                }
            });

            ctx.executeQueryAsync(function() { 
                console.log("Remove UserCustomAction");
            },function(s,a) {
                console.log("error", a.get_message());
            })

        }, function(s,a) { 
            console.log("error", a.get_message());
        });

});
  • Thank you very much for your professional answer. Followed your steps and the console.log answered "New Support files added to Site" - but the site won't load anymore now - I have a blank site. What did I do wrong? Or how can I go back to normal settings? – SteffPoint Mar 23 '18 at 10:20
  • 1
    @SteffPoint whats the error in the console? Just remove the content of the HideRetainCheckout.js. And I'll update my answer with how you remove a custom action too – Anders Aune Mar 23 '18 at 10:21
  • Uncaught ReferenceError: SP is not defined at <anonymous>:1:1 – SteffPoint Mar 23 '18 at 10:23
  • I unfortunately can't access anything of the site anymore – SteffPoint Mar 23 '18 at 10:26
  • What do you mean with you can't access it? You can't open "url to site/_layouts/15/viewlsts.aspx" ? – Anders Aune Mar 23 '18 at 10:30

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.