Please maintain attachments when using the append method on a hosted feature layer.
When following these instructions:
Append does not maintain attachments that are located in the hosted file geodatabase.
@ZacharyNeumannQK not sure if this is an idea, because you can select "Maintain Attachments" in the environment variables for Append
This is specifically for the ArcGIS API for Python. You cannot set that in an environment variable for the API... Unless you know something I don't know.
See Reference:
Second this idea! Unable to find way to maintain attachments. Looking to script adding attachments after append-but why the workaround for this?
def add_attachments(survey_monuments_fl, attach_table):
df = pd.read_csv(attach_table)
for s in zip(df['Path'], df['GlobalID']):
if not type(s[0]) == float: # make sure path is not empty
attach_path = os.path.join(project_folder_path, s[0])
globalid = s[1]
feature = survey_monuments_fl.query(where=f"GLOBAL_TEXT = '{globalid}'")
objectid = feature.value['features'][0]['attributes']['OBJECTID']
objectid = int(objectid)
update(f"Adding attachment {attach_path} to {objectid}")
survey_monuments_fl.attachments.add(objectid, attach_path)
files\win_20211007_09_30_26_pro.jpg |
and GlobalID
GlobalID |
{09804DA6-F682-48CA-8107-4X8102E16A54} |
I also needed to save GlobalID as a text field in the Feature Layer I am pretty sure because Esri likes to change those.
This is how I made the fl object
itemid = #itemidhere
survey_monuments_item = gis.content.get(f"{itemid}")
survey_monuments_fl = survey_monuments_item.layers[0]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.