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

Unable to create folders in document library after deploying SPFx Extension that loads javascript file

Open dmahendranme opened this issue 1 year ago • 4 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

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

Additional environment details

Describe the bug / error

We have a analytics tool that requires javascript file to be called. Created SPFx extension (App Customizer) to load the javascript file. Used SPComponentLoader.loadScript method to load a javascript file present in a site's style library.

javascript file has analytics code.

All SharePoint pages loads fine and everything is tracked in our analytics tool. I'm able to create documents in the library but i'm unable to create a folder. STRANGE!

Image Image Image

I tested it after the deleting the solution from app catalog, it worked.

Steps to reproduce

  1. Create SPFx extension -> Application customizer

public onInit(): Promise<void> { Log.info(LOG_SOURCE, `Initialized ${strings.Title}`);

const userName = this.context.pageContext.user.displayName;
(window as any).someconfig = {
  userName: userName
};
SPComponentLoader.loadScript('/Style%20Library/<javascript_snippet_file>.js');
return Promise.resolve();
  1. Deploy the solution and select "Make this solution available to all sites....."
  2. Navigate to any document library
  3. Create a folder

Expected behavior

You will receive "Illegal invocation" error on both console and UI

dmahendranme avatar Aug 02 '25 21:08 dmahendranme

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

Amey-MSFT avatar Aug 04 '25 03:08 Amey-MSFT

Hello @dmahendranme, 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!

Amey-MSFT avatar Aug 06 '25 13:08 Amey-MSFT

@dmahendranme: We're not always able to load from style library when you use "global deployment" as the js code might not be present in each site's style library. Next to that the actually loaded JS code might result in this behavior.

As we feel this is not a product issue we're closing this one. Feel free to re-open if needed.

jansenbe avatar Aug 14 '25 16:08 jansenbe

@jansenbe It's not about the loading JS. I see there is a misunderstanding on the issue from your response. We are hard coding the link to JS file from a site. Therefore, it works even if you deploy it globally. It does not check each site's style library as the link is hard coded. And this part works fine EVERY time. JS loads on all sites, and the analytics part works fine.

Please check with @Amey-MSFT because he/she is able to reproduce the issue. I'm unable to reopen the issue due to permission error.

dmahendranme avatar Aug 16 '25 20:08 dmahendranme