Select to view content in your preferred language

Feature Layer Overwrite Error - Data Referring to Another Service

10195
13
10-07-2015 02:28 PM
CodyYates
Deactivated User

I've been experiencing the following error for a few months now every time I try to overwrite my feature layer in order to update my Web Mapping Application that was built with the Web App Builder:

"User cant overwrite this service, using this data, as this data is already referring to another service."

My map is set up like this:

  • I uploaded a file geodatabase which created a feature layer.
  • I added the feature layer to a map, created symbology, and saved the layer and map.
  • I then create a Web Mapping Application by using the Web App Builder that pointed to the previously made Web Map and published it.

I'm unsure of how to update this map. I assumed I could just overwrite the feature layer with the updated file geodatabase, but I get that error each time and I'm not entirely sure what it means. I'm guessing that it can't update the layer while the Web Mapping Application still references it, but if that's the case, then how are you supposed to update the map?

I've been forced to just create a whole new layer each time and redo all of the symbology. There must be a better way to update a web map.

13 Replies
OGLEngineering
Occasional Contributor

Hello Cody, 


Did you ever solve this problem? I am having the same issue.

Thank you,

Sam

0 Kudos
MichaelMiller2
Frequent Contributor

I believe once you create a hosted feature layer in AGOL, a unique ID is generated for that feature layer. It sounds like when you attempt to 'overwrite' the feature layer it is generating a new unique ID for that feature layer.

Why not edit the feature layer in AGOL, then your edits will display in you app?

0 Kudos
OGLEngineering
Occasional Contributor

I am trying to edit the projection of the hosted feature layer. I don't know of a way to edit this through AGOL.

Funny thing is that this process worked for one hosted feature layer, but not for another one. They are both in the same map and web app. It's the first time I've seen this error, and there doesn't seem to be any documentation about it. 

0 Kudos
ScottStopyak
Frequent Contributor

I get the same error trying to use a script to update. It works fine if I manually use overwrite web layer in Pro. I wonder what Pro is doing to overcome this. I don't know why esri puts tools out there that don't have a way to implement via arcpy. Really annoying.

0 Kudos
ThomasColson
MVP Frequent Contributor

I'm getting the same error as you, using the same workflow, from Updating your hosted feature services with ArcGIS Pro and the ArcGIS API for Python | ArcGIS Blog.

0 Kudos
ThomasColson
MVP Frequent Contributor

Scott Stopyak‌ I found the issue behind ""User cant overwrite this service, using this data, as this data is already referring to another service."". From Updating your hosted feature services with ArcGIS Pro and the ArcGIS API for Python | ArcGIS Blog , the item search is executed with: 

sdItem = gis.content.search("{} AND owner:{}".format(sd_fs_name, user), item_type="Service Definition")[0]

Replace that with:

sdItem = gis.content.search(query="title:"+ sd_fs_name + " AND owner: " + user)[0]

The original search string was somehow causing the search to go boolean, which may or may not return the service name you had set with sd_fs_name, because it wasn't restricting the search to the item title. For example, if your service title was "BIG SASQUATCH", using the original search string would return the first item that had "SASQUATCH" any where in the title, tags, summary, or description, in my case, it would always return "SASQUATCH TRAINING". 

Accessing and creating content | ArcGIS for Developers  provided some insight on the correct way to format the search. 

Here's how I tested this: 

import arcpy
import os, sys
from arcgis.gis import GIS

sd_fs_name = "SASQUATCH"
portal = "http://www.arcgis.com" # Can also reference a local portal
user = "yabbayabbadoo"
password = "sasquatch"


print("Connecting to {}".format(portal))
gis = GIS(portal, user, password)

print("Searching for SD on AGOL...")
sdItem = gis.content.search("{} AND owner:{}".format(sd_fs_name, user), item_type="Service Definition")[0]
print("Found SD: {}, ID: {}".format(sdItem.title, sdItem.id))

print("Search for HFS on AGOL...")
hfsItem = gis.content.search("{} AND owner:{}".format(sd_fs_name, user), item_type="Feature Service")[0]
print("Found HFS: {}, ID: {}".format(hfsItem.title, hfsItem.id))

print("Search for HFS on AGOL using simple search...")
sshfsItem = gis.content.search(query="title:"+ sd_fs_name + " AND owner: " + user)[0]
print("Found ssHFS: {}, ID: {}".format(sshfsItem.title, sshfsItem.id))

ScottStopyak
Frequent Contributor

Thanks, Thomas!

0 Kudos
ConradSchaefer__DOIT_
Regular Contributor

Thomas Colson,

For my use, which may be different to others, when I used your (Thomas) modification I got another error saying the file type needed to be specified. I forget the exact error syntax but that was the gist. I took your mod and added the item_type= at the end. In my case it was a service definition file. The process ran.

So, I had success with the following tweak to your code:

sdItem = gis.content.search(query="title:"+ sd_fs_name + " AND owner: " + user, item_type="insert value here")[0]

As a side note, my code specifically said  item_type="Service Definition"

 

 

deactivated-user-ChrisBeaudett
Deactivated User

We saw this exact same behavior:  we're searching on a title of "MyServiceName" and it was returning the name of "MyServiceName_UAT" (we had both in AGOL), since the "_UAT"-named service was the first element in the returned array.  Found this very important bit of documentation:

It's important to understand that the search mechanism uses many different inputs to find possible matches, ranks them and returns appropriate results. The search becomes ideal for human interaction, but fuzzy when looking for specific records programmatically. The search results are non-deterministic. Using search may not necessarily be the best approach for finding specific items, but more a group of items from which to further filter.

Seems like the only way around this is to loop through the results and look for the exact item name/title, i.e. something like:

sdItems = gis.content.search(query="title:{} AND owner: {}".format(my_name, user), item_type="Service Definition")

if len(sdItems) > 0:

for item in sdItems:

if item.title == my_name:

sditem = item

break

else:

continue

else:   # assume that the one item found is the one you want

sditem = sdItems[0]

Or something like that. (Code above untested)

0 Kudos