0

I need to create java script which will show me the alert like Versioning is enabled or not for that document library when user open any document library.

Please let me know how I can achieve this by using java script any reference

3

Add content editor webpart on list view web page and add below code snippet

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js"></script><script>
$(document).ready(function () {
    $listName = ctx.ListTitle;
    $siteurl = _spPageContextInfo.webAbsoluteUrl;
    var url = $siteurl+"/_api/web/lists/getbytitle('"+$listName+"')?$select=EnableVersioning"
    getData(url).done(function (data) {
        console.log(data.EnableVersioning);
        if(data.EnableVersioning)
        {
            alert("Versioning is enalbe");
        }else
        {
            alert("Versioning is not enabled")
        }

})

})

getData = function (url) { return $.getJSON(url); };
</script>​​​​

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.