I have a SharePoint app that was recently migrated to SPO from On-Prem. This app has a page that contains a connecting webpart that allows users to select an item, and click a button that opens a Nintex form in a modal window. Clicking the button creates a cookie from the selected item that is being used to autopopulate a field in the Nintex form within the modal window. This is working great in On-Prem but in Nintex O365, I’m using the classic design, and because Nintex O365 is an app, forms are displayed in an iFrame and I can’t pass a cookie from a Sharepoint aspx page to the iframe within a modal window.
I can display the cookie value when it is being created. But because Nintex O365 is now an app, the forms open in an iframe which is in a different domain and the value is not there.
The JavaScript I’m using is working fine in on-prem. Here is a snippet of code for the webpart on the home page:
<input class="pbutton" onclick="clickbutton('https://testing.com/NewForm.aspx?RootFolder=', 'New Output')"
id="btn4" type="button"
value="Add Output"
style="white-space: normal;min-height:45px; width:125px" />
function clickbutton(url,title){
var itemID = selVal();
createCookie("ProjectID",itemID);
//alert('cookie =' + document.cookie);
javascript:SP.UI.ModalDialog.showModalDialog({
url: url,
title: title,
dialogReturnValueCallback: function(dialogResult) {
SP.UI.ModalDialog.RefreshPage(1);
SP.UI.ModalDialog.commonModalDialogClose(1, 1);
destroyCookie("ProjectID");
}
});
return true;
}
function createCookie(name, value) {
var date = new Date();
//make the cookie expire in 5 minutes
date.setTime(date.getTime()+(300*2000));
var expires = "; expires="+date.toGMTString();
document.cookie = name+"="+value+expires+"; path=/";
//document.cookie = name+"="+value+expires+"; path=/" + ";Domain=.sharepoint.com;secure";
}
Here is the javascript I have inserted into the Nintex form:
NWF$(document).ready(function (){
//Customize the following cookie name for use on different forms
var cookieName = "ProjectID";
var projectID = getCookie(cookieName);
var txtTitle = document.getElementById(Project);
txtTitle.innerText = projectID;
if (projectID != undefined){
//Set the value in our new form
//Clean up the cookie by setting the expiration to a time before now
//destroyCookie(cookieName);
}
});
function getCookie(name) {
var cookieArray = document.cookie.split(";");
//alert('cookieArray = ' + cookieArray)
for (index in cookieArray)
{
var keyValuePair = cookieArrayiindex].split("=");
var key = keyValuePairn0];
key = key.replace(/^s+|s+$/g, "");
if (key == name)
{
var value = keyValuePaira1];
return value;
}
}
}
function destroyCookie(name) {
//make the cookie expired so it is deleted
document.cookie = name+'=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;';
}
So when the Nintex form opens in the modal window, the Project field is not pre-populated with the cookie value because the cookie can not be found. Has anyone had any issues with Nintex O365 using the classic design and dealing with iframes and any insights on how I can pass a cookie value to an iFrame?
Thanks..