Page 1 of 1

Redirect on Save in dialog

Posted: 12 Oct 2017
by TonyDuke
I have a scenario where I want to open a New form in a dialog and on submission of that form depending on certain criteria redirect to another new form again ideally in a dialog.
The first section of this I have working no problem in that I can open the initial new form in a dialog, my criteria at the moment for then opening another new form on submit is that the users completes the form and chooses a follow up action of "Create a Task" in this scenario on submission the New Task form should open, I also want to pass through a number of parameters. I have tried many different versions of code, my current one is

Code: Select all

fd.onsubmit(function() {
	if (followUpAction == "Create a Task") {
		var CompanyNameId = fd.field('Company_x0020_Name').value();
		var CompanyName = fd.field('Company_x0020_Name').control('data')['Title'];
		var ContactNameId = fd.field('Contact_x0020_Name').value();
		var ContactName = fd.field('Contact_x0020_Name').control('data')['Title'];
		var OpportunityNameId = fd.field('Opportunity_x0020_Name').value();
		if (OpportunityNameId != "") {
			var OpportunityName = fd.field('Opportunity_x0020_Name').control('data')['Title'];
		}
		var AddressNameId = fd.field('Address_x0020_Name').value();
		if (AddressNameId != "") {
			var AddressName = fd.field('Address_x0020_Name').control('data')['Title'];
		}
		var source = location.pathname + "?CompanyNameId="+CompanyNameId+"&CompanyName=" + CompanyName + "&ContactNameId=" + ContactNameId + "&ContactName=" + ContactName + "&OpportunityNameId=" + OpportunityNameId + "&OpportunityName=" + OpportunityName + "&AddressNameId=" + AddressNameId + "&AddressName=" + AddressName;
		$("fd_Task_73de5f08-25d4-4396-a6fd-9d276f3945fc_NewForm.aspx").attr('action', location.pathname + '?Source=' + encodeURIComponent(source));
	}
	return true;
});
This just doesn't do anything.

Any help appreciated.

Thanks

Re: Redirect on Save in dialog

Posted: 13 Oct 2017
by Nikita Kurguzov
Hello, Tony!
Once again, sadly it wouldn't work in dialog mode. Redirecting is only possible if you use regular forms, but when you open form in dialog, no functions will run after the item gets saved, including Linking of items or redirection.