Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / productivity / SharePoint / SharePoint2013

Open infopath Form in SharePoint Modal Popup Window

5.00/5 (1 vote)
6 Jul 2016CPOL 12.7K  
Let us discuss how to open InfoPath form in SharePoint modal popup window in SharePoint 2013

Introduction

Add the below code in your page to open infopath form in SharePoint modal popup window.

Add hyper link in the page:

HTML
<a href="#" class="infopathform"> Click here to open the form </a>

Open the page and add the below code in PlaceHolderAdditionalPageHead section.

JavaScript
$(document).on('click', '.  infopathform  ', function () {
    openMyDialog();
});

var InfoPathCheck;

function openMyDialog()  
{ 
  var options = { 
    url: "/_layouts/15/FormServer.aspx?XsnLocation="+_spPageContextInfo.webAbsoluteUrl +
    "/FormServerTemplates/BICCReportForm.xsn&SaveLocation="+_spPageContextInfo.webAbsoluteUrl +
    "%2FReport%20Request&ClientInstalled=false&DefaultItemOpen=1&Source="+
    _spPageContextInfo.webAbsoluteUrl+"%2FReport%2520Request%2FForms%2FAllItems%2Easpx", 
    title: "Request a New Report", 
    dialogReturnValueCallback: function (dialogResult)  
    {       
       if(dialogResult==1){
       
     SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', Alertoptions );
       } 
    }, 
    allowMaximize:false 
  }; 
 
SP.SOD.execute('sp.ui.dialog.js', 'SP.UI.ModalDialog.showModalDialog', options);
}

Either change URL in the code or copy the URL from your site by navigating to library and open the form. Copy the URL from browser and paste it in the code.

  • FormName - your infopath form name
  • LibraryName- where you published your infopath form
HTML
"/_layouts/15/FormServer.aspx?XsnLocation="+_spPageContextInfo.webAbsoluteUrl +
"/FormServerTemplates/FormName.xsn&SaveLocation="+
_spPageContextInfo.webAbsoluteUrl +
"%2FLibraryName&ClientInstalled=false&DefaultItemOpen=1&
Source="+_spPageContextInfo.webAbsoluteUrl+
"%2FLibraryName%2FForms%2FAllItems%2Easpx"

History

  • 5th July, 2016 - Initial version created

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)