sp-dev-docs icon indicating copy to clipboard operation
sp-dev-docs copied to clipboard

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

Open Youssef-El-Garmit opened this issue 1 year ago • 1 comments

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

  • [ ] 💥 Internet Explorer
  • [X] 💥 Microsoft Edge
  • [ ] 💥 Google Chrome
  • [ ] 💥 FireFox
  • [ ] 💥 Safari
  • [ ] mobile (iOS/iPadOS)
  • [ ] mobile (Android)
  • [ ] not applicable
  • [ ] other (enter in the "Additional environment details" area below)

Additional environment details

  • browser version
  • SPFx version
  • Node.js version
  • etc

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 avatar Oct 01 '24 23:10 Youssef-El-Garmit

Capture d'écran 2024-10-02 013322 Capture d'écran 2024-10-02 013553

Youssef-El-Garmit avatar Oct 01 '24 23:10 Youssef-El-Garmit

Hello @Youssef-El-Garmit, Thank you for bringing this issue to our attention. We will look into it and get back to you shortly.

Ashlesha-MSFT avatar Apr 22 '25 05:04 Ashlesha-MSFT

@Youssef-El-Garmit, Can you please confirm how you are Modifying the NewFormUrl with a custom URL. Please give us more detailed repro steps

Ashlesha-MSFT avatar Apr 22 '25 07:04 Ashlesha-MSFT

@Youssef-El-Garmit, Can you please confirm how you are Modifying the NewFormUrl with a custom URL. Please give us more detailed repro steps

Hello @Ashlesha-MSFT ,

Of Course i use the pnp js, and here is my code :

list.contentTypes.getById(itemContentTypeList.Id.StringValue).update({DisplayFormUrl: displayFormUrl, NewFormUrl: newFormUrl, EditFormUrl : editFormUrl });

But as i said in the first message, even without modifying the url of redirect it you can reproduce the error just by :

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 avatar Apr 24 '25 14:04 Youssef-El-Garmit

Hello @Ashlesha-MSFT @VesaJuvonen,

Do you have some news about this issue ?

Youssef-El-Garmit avatar Jun 02 '25 14:06 Youssef-El-Garmit

@Youssef-El-Garmit Apologies for the delayed response, and thank you for your clear explanation. Image

We were able to reproduce the issue, and we are investigating it. We have logged this as a bug, and our engineering team will look into it. Thank you for your patience!

Ashlesha-MSFT avatar Jun 03 '25 11:06 Ashlesha-MSFT

Thanks for your feedback. After consulting with the respective engineering teams we've learned this approach is not supported and therefor we're closing this issue.

jansenbe avatar Sep 10 '25 19:09 jansenbe