item.update() is breaking WAB apps

375
3
Jump to solution
10-01-2019 07:47 PM
AngusHooper1
Occasional Contributor II

Morning,

I am trying to create a script that searches an items dependencies & data, finds legacy URL's/services and updates these to the new version of that URL/service.

Example of script

orig_data = item.getdata()

new_data = orig_data.replace(old_url, new_url)

item.update(item_properties=None, data=new_data, thumbnail=None, metadata=None)

The outcome of this script, when used with WAB Apps, is the app breaking and returning an error page of "'False' is undefined". What is wrong with the above methodology for WAB Apps? Is there an alternative workflow to achieve the same end goal of updating legacy dependencies that are baked into a WAB App?

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
EarlMedina1
Occasional Contributor III

Okay, if that is what you're trying to update the workflow you described isn't quite what I had in mind. What happens if instead you do:

app_data = item.getdata()
app_data['geometryService'] = 'https://thisisanupdate.com'
item_properties = {"text": json.dumps(app_data)}
app.update(item_properties=item_properties)

This update is successful for me and the application continues to work.

View solution in original post

3 Replies
EarlMedina1
Occasional Contributor III

Hi Angus,

Exactly what are you trying to update in the app? URLs defined in widgets (e.g., Geoprocessing Widget task URL)? Those would appear in the Web Application item data, otherwise any displayed layers should come from the underlying Web Map.

-Earl

0 Kudos
AngusHooper1
Occasional Contributor II

The geometry service that the Portal is configured to use is baked into the WAB app data. This is not configurable in the app, a widget or web map.

0 Kudos
EarlMedina1
Occasional Contributor III

Okay, if that is what you're trying to update the workflow you described isn't quite what I had in mind. What happens if instead you do:

app_data = item.getdata()
app_data['geometryService'] = 'https://thisisanupdate.com'
item_properties = {"text": json.dumps(app_data)}
app.update(item_properties=item_properties)

This update is successful for me and the application continues to work.