Introduction
Add the below code in your page to open infopath form in SharePoint modal popup window.
Add hyper link in the page:
<a href="#" class="infopathform"> Click here to open the form </a>
Open the page and add the below code in PlaceHolderAdditionalPageHead
section.
$(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
"/_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