Page 1 of 1

Open NewForm of another content type in dialog

Posted: 13 Nov 2018
by Oz.Ab
Hi guys.

Here is my situation, with my custom list.

1. I open up a Display Form in the browser which is content type A (not dialog).
2. I click a custom button on the Display Form which opens a New Form (content type B) in a dialog.

The Custom Button on the Display Form of content type A has this:
-----------------------------------------------
var webUrl = _spPageContextInfo.webServerRelativeUrl;
//The path to content type B New form
var listNewForm = "/Lists/X/fd_B_000_NewForm.aspx";

// open target form
fd.openFormInDialog(webUrl + listNewForm);
-----------------------------------------------
My New Form opens correctly. But the funky thing is that when I save the New Form I am not creating a new item, I am overwriting the item which is open in the Display Form!

I noticed that when I view the properties of the New Form (dialog) the URL contains "&Source= theURL and ID of the item seen in Display form".


My question is: What js needs to be behind my custom button so that it defenitely opens up the NEW FORM of content type B and saves it as a new item?

Re: Open NewForm of another content type in dialog

Posted: 14 Nov 2018
by Nikita Kurguzov
Dear Oz,
This is really strange, it shouldn't happen assuming the New Form has opened properly. We'll need to see the URL used in the dialog to say what's going on.

Could you please, find an iframe on the page where the dialog form is embedded (.ms-dlgContent -> .ms-dlgBorder -> .ms-dlgFrameContainer), and send us a screenshot, which includes both the URL of the opened page, and the URL used in dialog, like this:
DialogURL.png
DialogURL.png (147.85 KiB) Viewed 2215 times

Re: Open NewForm of another content type in dialog

Posted: 16 Nov 2018
by Oz.Ab
Hihi, I just sent you a private message with the screenshot.

Re: Open NewForm of another content type in dialog

Posted: 26 Nov 2018
by Oz.Ab
Any ideas? Did you get my screenshot?

Re: Open NewForm of another content type in dialog

Posted: 04 Dec 2018
by Oz.Ab
Hi Nikita - did you receive the screenshot I sent you?

Re: Open NewForm of another content type in dialog

Posted: 04 Dec 2018
by Nikita Kurguzov
Dear Oz,
Sorry for the delay. From the screenshot, it seems like you are actually opening New Form of the same list with the same Content Type, just a different form set, and when you do this, the ID is also passed with the use fd.openFormInDialog()

We've tested this scenario, and to avoid this, we recommend to use the following for opening form in dialog:

Code: Select all

fd.openFormInDialog(webUrl + listNewForm, {ID:null});

Re: Open NewForm of another content type in dialog

Posted: 05 Dec 2018
by Oz.Ab
Thankz Nikita - it works like a charm :)

Re: Open NewForm of another content type in dialog

Posted: 05 Dec 2018
by Nikita Kurguzov
Dear Oz,
You are very much welcome! It did takes us some time to figure out and test, so, sorry for the delay, but if you need anything - just let us know, we're sure to help! :)