Can anyone help with this?
Hi,
have you tried using a dialogReturnValueCallback parameter?
I've found an interesting thread on stack overflow that could help you out:
http://stackoverflow.com/questions/8426773/how-to-refresh-a-parent-page-after-closing-sharepoint-dialog
Hi Giacomo,
I have tried amending the code but I don't think I have this right at all.
I need to close the diag modal window when either the Submit or Cancel button on the Nintex workflow Initiation form is selected.
function openStartDialog( pUrl ) {
var options = {
url: pUrl,
width: 750,
height: 567,
title: "Start Capita Task",
dialogReturnValueCallback: ClosePopUp
};
SP.UI.ModalDialog.showModalDialog(options);
}
function ClosePopUp(result, returnValue)
{
if (result==SP.UI.DialogResult.OK)
{
SP.UI.ModalDialog.commonModalDialogClose(1,1);
}elseif
(result==SP.UI.DialogResult.Cancel)
alert ("Test");
{
SP.UI.ModalDialog.commonModalDialogClose(1,1);
}
}
Hi Darren,
sorry, I've maybe a little misunderstood your request and I've not thought about the workflow start page, so the suggestion I've given you doesn't work (it doesn't get the value from the start/cancel button so it doesn't use the dialogReturnValueCallback and it's not capable to close the dialog..
Unfortunately I'm not so high-skilled in javascript to solve this (if it has a js solution) or to propose a different kind of solution..
Maybe someone else here on the forum could help you more.. I hope so!
Giacomo
Hi Giacomo, no problem.
I think there will need to be some call (javascript- function) behind the buttons on the start form to somehow call the parent Diag modal window to close it after posting the data to the server (start workflow) or cancelling the workflow.
Anyone out there know how to do this?
OK, so I appear to be getting somewhere,
I have set both the create task and cancel buttons to call a function that will close the Diag Modal window,
In advanced settings of each button, under client click I added the following:
NWF$(document).ready(function()
{
SP.UI.ModalDialog.commonModalDialog(1,1);
}
);
This works a treat for the cancel button, but for the create task button that is a 'Save and Submit' button, it causes the window to close before starting the workflow.
I need some script/extra code to check that the workflow has started/posted the data, then call the code/function that closes the window (as above).
Hi Darren,
Are the field values on the initiation form entered by the user or do they match list item values? Depending on your requirements here I may have an alternative approach that could be a bit simpler.
Jan
Hi Jan,
the user enters some values. However, if need be I can pul the Values from a list. What solution do you have in mind?
Hopefully I've understood the problem correctly but if not please let me know!
If you can pass in the start variables without using the workflow start form then you can just kick off the workflow directly using script and pass in the start variables in the association data, so you can potentially remove the need for a modal dialog.
I've pasted some code below that will do the basics, the association data passes in the name(s) of the variables on the workflow start form so in my example I've got one workflow variable called startVariableText and I'm passing a value of "hello world".
function StartMe()
{
var associationData = encodeData("<Data><startVariableText>hello world</startVariableText></Data>");
startworkflowonlistitem("your workflow name", your list item id, "your list name", associationData);
}
function encodeData(input)
{
return input.replace(/&/g, "&").replace(/>/g, ">").replace(/</g, "<");
}
function startworkflowonlistitem(wfName, itemId, listName , associationData)
{
var webMethod = _spPageContextInfo.webAbsoluteUrl + '/_vti_bin/NintexWorkflow/Workflow.asmx';
var soap= "<?xml version=""1.0"" encoding=""utf-8""?>" +
"<soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd=""http://www.w3.org/2001/XMLSchema" xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/">" +
"<soap:Body>" +
"<StartWorkflowOnListItem xmlns=""http://nintex.com">" +
"<itemId>" + itemId + "</itemId>" +
"<listName>" + listName + "</listName>" +
"<workflowName>" + wfName + "</workflowName>" +
"<associationData>" + associationData + "</associationData>" +
"</StartWorkflowOnListItem>" +
"</soap:Body>" +
"</soap:Envelope>";
NWF$.ajax({
type: "POST",
url: webMethod,
beforeSend: function(xhr) { xhr.setRequestHeader("SOAPAction", "http://nintex.com/StartWorkflowOnListItem");},
data: soap,
contentType: "text/xml; charset=utf-8",
dataType: "xml",
success: function(data) {alert("The workflow has been started");},
error: function (e) { alert('The workflow has failed to start'); } });
}
Hope that helps but let me know if you're still stuck.
Jan