SharePoint / sp-dev-docs

SharePoint & Viva Connections Developer Documentation
https://docs.microsoft.com/en-us/sharepoint/dev/
Creative Commons Attribution 4.0 International
1.25k stars 1.01k forks source link

Service Worker redirect page to error when ID is set don't exist or when List param is set without ID param #9947

Open Youssef-El-Garmit opened 1 month ago

Youssef-El-Garmit commented 1 month ago

Target SharePoint environment

SharePoint Online

What SharePoint development model, framework, SDK or API is this about?

💥 SharePoint Framework

Developer environment

Windows

What browser(s) / client(s) have you tested

Additional environment details

Describe the bug / error

Hello

Issue Summary: When modifying the NewFormUrl in SharePoint Online with a custom URL, the parameters List, Source, and ContentTypeId are automatically appended to the URL when clicking on a new item in the list. However, this results in an error on the new form page because it attempts to retrieve an Item ID that does not exist, likely due to a service worker issue. Additionally, adding an ID parameter to any page URL for custom use also results in an error.

Steps to Reproduce:

Modify the NewFormUrl with a custom URL. Click on a new item in the list where the content type has been changed. Observe that the URL includes the parameters List, Source, and ContentTypeId. Notice the error on the new form page as it tries to fetch a non-existent Item ID. Add an ID parameter (e.g., ID=23) to any page URL and observe the resulting error. Expected Behavior: The new form page should load without attempting to retrieve an Item ID, allowing users to create new items without encountering errors. Additionally, adding an ID parameter to any page URL should not result in an error.

Actual Behavior: The new form page displays an error because it tries to get an Item ID that does not exist in the new form context. Similarly, adding an ID parameter to any page URL results in an error.

Additional Information: This issue appears to be related to the service worker handling the request. Any insights or fixes would be greatly appreciated.

Steps to reproduce

1.Add for example ?ID=999999 in any page 2.You will have an error

1.Add a param ?List={PUT HERE REAL LIST GUID} in any page without ID param and you will have an error

Expected behavior

The page should display, so that i can display my custom new form webpart

And in the case of ID, if we are not in the contexte of a list the page should display so that i manage the error my self

Youssef-El-Garmit commented 1 month ago
Capture d'écran 2024-10-02 013322 Capture d'écran 2024-10-02 013553