Open NewForm of another content type in dialog

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
Oz.Ab
Posts: 39
Joined: Mon Oct 09, 2017

13 Nov 2018

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?

User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

14 Nov 2018

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 2209 times
Cheers

Oz.Ab
Posts: 39
Joined: Mon Oct 09, 2017

16 Nov 2018

Hihi, I just sent you a private message with the screenshot.

Oz.Ab
Posts: 39
Joined: Mon Oct 09, 2017

26 Nov 2018

Any ideas? Did you get my screenshot?

Oz.Ab
Posts: 39
Joined: Mon Oct 09, 2017

04 Dec 2018

Hi Nikita - did you receive the screenshot I sent you?

User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

04 Dec 2018

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});
Cheers

Oz.Ab
Posts: 39
Joined: Mon Oct 09, 2017

05 Dec 2018

Thankz Nikita - it works like a charm :)

User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

05 Dec 2018

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! :)
Cheers

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 22 guests