I designed a custom webpart to display list items as cards. For this I created a custom "new item" button and also try to open the display form when clicking at the element title.
At first the iframe opens the default form (e.g. "DispForm.aspx?IsDlg=1"). But as soon as the form gets loaded, the whole website gets redirected to the plumsail form.
Logging in the console shows:
Panel mounted
URL: "/sites/mySite/Lists/Tickets/NewForm.aspx?IsDlg=1"
spredirect.js:1 /sites/mySite/SitePages/PlumsailForms/Tickets/Tickets/NewForm.aspx
Navigated to https://<mytenant>.sharepoint.com/sites/mySite/SitePages/PlumsailForms/Tickets/Tickets/NewForm.aspx
If we load the plumsail form direct by passing the "correct" url, it loads just fine in the panel without redirecting the parent (but that's not possible, because we use the "listinfos => forms" from @pnp/sp/forms rest call to get the "default" forms)
Dear @Hagrid,
An interesting case, but the details are a little vague... Would you be able to attach some screenshots or maybe a short of video of what this looks like in your environment? I just want to get the full picture.
Dear @Hagrid,
How does the custom iFrame know what form to open? Can you just use the final URL of the form in the iframe?
The issue is that before any specific form is opened, you get a redirect page which selects which form to open. We avoid it in our panel, of course, but this could happen with custom solutions.
If I use the final URL, everything opens correctly without redirecting: url = "/SitePages/PlumsailForms/Test3/Tickets/NewForm.aspx?IsDlg=1"
But I want to develop a general webpart. This means that not all forms are necessarily provided via Plumsail.
Is it possible to get the final plumsail form url by any query or can I avoid the redirect?
Dear @Hagrid,
I see! This is what you can try, though, be wary it's not recommended and it's an undocumented trick (so, it's functionality is subject to change in some ways).
Our redirect page detects whether the form is opening in our dialog or in the full window by the following property: typeof window.frameElement.__fdCloseDialog === 'function'
If the property exists, 'redirect' opens the form in the same window and the above function is called when a user closes the form.
So you need to obtain the iframe from DOM and attach '__fdCloseDialog' field to it:
Hello @Hagrid ,
I have the same issue, can you share the code you used to associate the __fdCloseDialog function into your iframe component ?
Thank you !
David
Thank you @Hagrid for your reply. Meanwhile I have managed to figure it out by adding the sandbox attributes in the iframe element:
**<iframe src='https://mysite.com' frameBorder='0' sandbox='allow-modals allow-scripts allow-same-origin'>
Cheers