Apr 19 2018 01:19 PM
I recently created a custom web part and deployed it to our SharePoint online site. I can add the part to a Site Page with no problems, it saves and publishes with no errors. Everything works as expected until you navigate away from the page. When the page opens again the web part is gone. If you edit the page you can see that there is an empty web part where the custom one should be. I get the same result from adding the part to an existing section as I do when I give it it's own section. I've tried rebuilding the part, changing the version number, deleting and re-adding and creating a version that consists of just the word "Test" all with the same results. I haven't found anything online so I'm hoping someone here can let me know what I'm missing.
Apr 20 2018 07:35 AM
Hey Daniel can be a multitude of things. My first stop would be the Chrome developer tools... reload the page and look for any errors that may be related to your custom web part. It may be a resource file isn't found, it may be permissions, it may be a missing semi-colon :) Good luck!
Apr 20 2018 09:55 AM
Thanks for the suggestions!
I double checked the console but still don't see anything relevant. Chrome shows no errors, some depreciated property warning and some non-registered setting warnings, none of which appear related to the web part. The only error I see on the page is when running it in Safari which throws a 404 error for ActivityMonitor.js.map as well as the same warnings I see in Chrome. All of these errors and warnings show up on pages without the web part and on other sites in our tenant.
I'm not seeing anything that would indicate, to me at least, that there is a permission issue or missing resource. The part works as expected after adding it to the page - it's pretty simple and has three options that can be toggled on and off (one inserts a JavaScript and the other two insert CSS styles) and a full-width red div so I can see that it's actually there. I can save drafts, publish and edit the page and change the web part settings. I get the depreciated warnings on publish and edit but no errors. If I view the page in a different tab or browser the web part is not shown. However, if I come back to the original page (left open after publishing) the part is still there, if I edit the page it's still there and works normally. Refreshing the page or navigating away and back will make it disappear with no new warnings or errors. It doesn't appear to matter if the options are on or off.
I don't see any errors in Visual Studio Code and all of the semi-colons (as well as commas which I have a bad habit of forgetting in property lists when I'm in a hurry) appear to be where they should be.
Apr 21 2018 05:31 AM
Apr 23 2018 06:35 AM
Thanks. I've run the enable command and will give it another try tomorrow.
Apr 24 2018 12:42 PM
I tried it again this afternoon and had a moment of hope. I was able to navigate away from the page then back again and it was still there. Unfortunately, when I tried to open it in another tab the part disappeared again. Refreshing the page causes it to disappear as well so it may have just been showing due to browser caching.
Apr 24 2018 12:44 PM
What kind of web part is it? A content editor web part with code directly in it or something else?
Apr 25 2018 06:52 AM
I'm afraid that I don't quite understand your question. This is the first web part I've built and I don't recall there being any other type information beyond "WebPart" when I set it up.
It inserts a div with a single line of text and some basic CSS styling and has three components that can be toggled on and off; one JavaScript and two CSS styles.
May 23 2019 01:28 AM
@Daniel Lyons III I am facing the same issue. Is there any solution?
Jul 07 2019 12:07 AM
Jul 08 2019 08:59 AM
If I remember correctly, the solution was to enable the Office 365 CDN to host the web parts.