SPFx Form Customizer - error using env=Embedded URL parameter for SPListForm.aspx
Target SharePoint environment
SharePoint Online
What SharePoint development model, framework, SDK or API is this about?
💥 SharePoint Framework
Developer environment
None
What browser(s) / client(s) have you tested
- [ ] 💥 Internet Explorer
- [x] 💥 Microsoft Edge
- [x] 💥 Google Chrome
- [x] 💥 FireFox
- [ ] 💥 Safari
- [ ] mobile (iOS/iPadOS)
- [ ] mobile (Android)
- [ ] not applicable
- [ ] other (enter in the "Additional environment details" area below)
Additional environment details
- SPFx version 1.18.2
- Node.js version 18.17.1
Describe the bug / error
I`m using SPFx Form customizer to customize the SharePoint list form (https://learn.microsoft.com/en-us/sharepoint/dev/spfx/extensions/get-started/building-form-customizer).
In this case, SharePoint redirects me to the SPListForm.aspx page where I have a few parameters in the URL.
Now, I'm trying to use URL parameter env=Embedded as described here https://learn.microsoft.com/en-us/microsoft-365/community/query-string-url-tricks-sharepoint-m365#put-nearly-anything-in-sharepoint-into-focused-mode.
And it shows me an error:
Details from the Network show more info:
After debugging of SharePoint scripts, I found out that it fails when trying to render Navigation (window.o365ShellLoadPromise is undefined, and it camsd somwhere from the logic that tries to render SuiteNav):
I think this is because the variable (_isSuiteNavDisabled) that responds to running this code returns false.
And here is the method (I suppose) that sets it
If I manually, during debugging, set _isSuiteNavDisabled to true, then the form renders without errors.
I think this is a bug in a script on SPListForm.aspx because the param env=Embedded should render the form without any navigation and errors.
It would be good if someone could check this, because usage of env=Embedded is officially allowed and should work in such extensions as Form Customizer
Steps to reproduce
- Create SPFx with form customizer
- Upload it to SharePoint and try to redirect to e.g. NewForm.aspx with param env=Embedded in the URL (https://..../NewForm.aspx?env=Embedded)
- SharePoint will redirect to SPListForm.aspx, env=Embedded present in the URL.
- Error occurred.
Expected behavior
If env=Embedded used for the form customized with Form Customizer no error should occure on rendering the page
Hello @vlad-nvs, Thank you for bringing this issue to our attention. We will look into it and get back to you shortly.
@vlad-nvs, We were able to successfully reproduce the issue you reported regarding SPFx Form Customizers failing when used with the env=Embedded URL parameter.
We tested several potential workarounds. Unfortunately, none of the workarounds were successful - the fundamental incompatibility persists across all scenarios.
We will be raising this as a bug with the engineering team for investigation and resolution.
Can confirm the issue when including any "env" parameter in an url of a Form Customizer.
@vlad-nvs, In my tests, SPListForm now seems to have the capability to automatically show the form in Focus Mode if it is included within an IFrame, even if the "env" parameter is not set explicitly. So in case you are embedding the form in an IFrame, you could try dropping the "env" parameter for now and check if your form is still displayed in Focus Mode.
Hi @fheinicke. Yes, with an iframe form loaded in a Focus Mode.
Unfortunately, this cannot cover all cases, especially if direct links are used to open forms, e.g., from emails. And the error totally blocks the possibility of working with the site or list, or form, because it redirects to an error.aspx page. This looks strange because the actual error is in the scripts and not on the server, as I understood.
Hope it can be fixed.
@vlad-nvs / @fheinicke : thanks for reporting this issue. We do not officially support using the env=embedded url parameter when loading SharePoint pages. This was documented by the community as it can help in certain cases, but it's not officially supported feature.
Given it's unsupported we're closing the issue.