Upload “Power BI Files” only to “Power BI Library” in SharePoint site

If you want to restrict to only upload Powe BI file (.pbix file) to “Power BI Library” as below screenshot, you can use following JQuery code in HTML masterpage.

//Check upload file extension is PowerBI files - only for Power BI Library
CheckAssetLibMediaExtension = function(){

if (window.parent.location.pathname.toLowerCase().indexOf('powerbifiles')>0)
{
      var allowedExtensions = /pbix/;

      var inputFile = $("input[name$='InputFile']").val();

      var ext = inputFile.substr(inputFile.lastIndexOf('.') + 1);

     console.log(ext);

      //var
     $currentIFrame = $('.ms-dlgFrame');

    if (!allowedExtensions.test(ext)) {
          $("input[name$='btnOK']").attr('disabled','disabled');

           alert('Only Power BI file with file extension name is .pbix can be uploaded                  to this library.');

 $currentIFrame.contents().find("body .ms-error").css('display','block !important');

//$currentIFrame.contents().find("body .ms-error>span").text("Only Power BI file (file extension is '.pbix') can be uploaded to this library.");

  } else
  {
         $("input[name$='btnOK']").removeAttr('disabled');
   }
}
}
This post is part of my project "Implement the Business Intelligence On Premises SharePoint 2013 Portal".
If you want to know more my experiences from the guide of above project, please sign up in here.

Recommend books:
  

Comments

Post a Comment

Popular posts from this blog

Top JavaScript courses helping you develop SPFx webPart with ReactJS and AngularJS

Effective LLM Prompting skills