Web AppBuilder threw away my code again

1016
6
08-30-2017 06:05 AM
DavidWendelken
Occasional Contributor

I've learned that I need to back up the app I'm working on before I make any changes that will require me to press the SAVE button.  That's because it will occasionally throw away all the widgets in the app and delete their code.

Today, I started up web appbuilder.  Opened up my app and added a widget to it, then pressed save.

It just happened deleted code again.  Here's what the relevant console log shows, less the date time stamps and the true server and custom widget names:

...................Repository items refreshed.................
[INFO] server - Portal https://myUrl.com/arcgis uses web-tier authorization.
[INFO] server - Set isXT = true; /webappbuilder/stemapp/env.js
[INFO] server - Set isXT = true; /webappbuilder/apps/2/env.js
[DEBUG] utils - copy D:\esri_webappbuilder_2\client\stemapp\widgets\myCustomWidget3
[INFO] app - remove widget AddData from app 2
[INFO] app - remove widget BasemapGallery from app 2
[INFO] app - remove widget Measurement from app 2
[INFO] app - remove widget myCustomWidget1 from app 2
[INFO] app - remove widget myCustomWidget2 from app 2
[INFO] app - remove widget myCustomWidget3 from app 2
[INFO] server - Portal https://myUrl.com/arcgis uses web-tier authorization.
[INFO] server - Set isXT = true; /webappbuilder/stemap/env.js

Because of this behavior, I've learned to back up the app before I add a widget or change the basemap, etc.  This is an especially pernicious defect because if you're in the midst of writing a custom widget in your app, it literally deletes the widget code from the app!


Tags (1)
0 Kudos
6 Replies
KenBuja
MVP Esteemed Contributor

Have you set up your development environment to create new widgets as suggested by Robert Scheitlin, GISP‌ in this discussion?

When developing new custom widgets the widget/theme development work flow I use for all my work is this.

1. Copy the [install dir]\client\stemapp\widgets\samplewidgets\CustomWidgetTemplate folder to the stemapp widget folder and rename it to your custom widgets name.
2. Open the manifest.json and change the name property to the exact name of the widget folder from step one.
3. I now work on changing the icon and some basics of the widget.
4. Now I create a new app (normally the app will be named the same as my custom widgets name) and will see that my new custom widget is a choice in the widget choices.
5. Add my custom widget to the new app.
6. Now I do ALL my development in the [install dir]\server\apps\[app #]\widgets\my custom widget name folder.
7. Once I am done will my development I copy the widget folder back into the stemapp widgets folder so that new apps will use the completed widget code.

DavidWendelken
Occasional Contributor

I do!  I ran across his post awhile back and have been following his good advice since.

It's possible that today's problem was triggered by a typo in the changes to the custom template I started with.   I re-did the template copy / modify step 1&2 twice before it worked.  

But I've had this problem crop up in the past when I've added a plain vanilla, out of the ESRI box widget to my app, so it's not the only possible trigger.

0 Kudos
KenBuja
MVP Esteemed Contributor

So far I haven't run into your problem of a disappearing widget, but it is good to keep that in the back of my mind. I use a GitHub repository to save my widget code...I'll have to make sure I save it more often.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

The only time I can think of that I saw this is when I switched themes. With as much development as I do if this was a major flaw in WAB I would have expected to see it more often. Not real sure what to tell you.

0 Kudos
DavidWendelken
Occasional Contributor

I don't know what to do about it either other than back up the entire app before I make any change that requires the save button to be pushed.

The first time this happened to me I only lost a few hours of work.   It could have been a whole lot worse. 

It's so totally unexpected to have an application go into wholesale "delete code mode" when you press "Save" that I wanted to get this info out there. 

0 Kudos
KenBuja
MVP Esteemed Contributor

Take a look at this video from the last DevSummit. One of the things it covers is how to use a Yeoman generator and Grunt so that the widget code is kept in a separate location, but a watch is kept on any changes you make to your code. These are then automatically copied into the WAB directory and show up when you refresh the page. Other videos from the Summit are available here.

Web AppBuilder for ArcGIS Advanced Development Tools and Techniques - YouTube 

Here's the GitHub site from the talk:

GitHub - Esri/generator-esri-appbuilder-js: Yeoman generator to help customize Esri's WebAppBuilder 

0 Kudos