Open SP Modal from Nintex Form

  • 1 August 2017
  • 1 reply
  • 83 views

I am working on a Nintex Form in Office 365 and want to open a modal window from a link within the form to be able to add documents to a document library. We are doing this because the form has multiple sections and the simple attachments field was not robust enough for our needs. I have the modal working in my site from a SP page, but when I implement the same code within my form I get this error:

 

Uncaught TypeError: SP.UI.$create_DialogOptions is not a function

 

I tried adding the SP.js file to my form, but this did not fix it. I'm assuming it's because I'm not actually in SP anymore when I'm in the form so I can't use functions from it.

 

Here is the javscript I'm running to open the dialog:

 

//Dialog Opening -- Document Uploads
function OpenDocumentDialog(refID, sectionName, modalTitle) {
console.log("createDialog");
var options = SP.UI.$create_DialogOptions(); <-- where my script errors out
options.url = "[mysiteURL]/_layouts/Upload.aspx?List=%7BB18DF216-5909-4DC1-90C6-8F4305C86F90%7D&ideaSect=" + sectionName +"&refID=" + refID;
options.title = modalTitle;
options.dialogReturnValueCallback = Function.createDelegate(null, CloseCallback);
console.log(options);
SP.UI.ModalDialog.showModalDialog(options);
}


function setAttachmentLinks(isNew, isEdit, currentId)
{
....
console.log("Edit mode: start updating button links - modal");
var a = document.getElementById('TitleAttachmentLink');
a.onclick= function() { OpenDocumentDialog(currentId, 'Title', 'New Attachment: Title Section') };

 

var a2 = document.getElementById('ThemeAttachmentLink');
a2.onclick= function() { OpenDocumentDialog(currentId, 'Theme/Backstory', 'New Attachment: Theme/Backstory Section') };

 

var a3 = document.getElementById('MechanicAttachmentLink');
a3.onclick= function() { OpenDocumentDialog(currentId, 'Mechanic', 'New Attachment: Mechanic Section') };

 

}

 

I think if I can call/create/access the SP context, this will work. Is this possible?  Thanks!


1 reply

Badge +1

@agi


were you able to resolve your modal issue? I have the same scenario, i am trying to display list content when clicking on button within the form

Reply