-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Is your feature request related to a problem? Please describe.
I am trying to automate creation of hosted joined views, as we use many of them that must be maintained to standards across AGO organizations.
I am led to believe that this is the intended output of this method, but can not figure it out: https://developers.arcgis.com/python/latest/api-reference/arcgis.gis.toc.html#arcgis.gis.ViewManager.create_join_layer
For example, some of my latest attempt:
from arcgis.gis._impl._dataclasses._viewdc import JoinType
from arcgis.features import FeatureLayer, FeatureLayerCollection, Table
flc_item = gis.content.search(rf"id:<hfl_itemid>", item_type="Feature Service")[0]
for lyr in flc_item.layers:
if (len(lyr.properties['relationships']) > 0):
# Initialize feature layer collection from URL of specific layer
flc = FeatureLayerCollection(flc_item.url + r"/" + str(lyr.properties.id))
for rel in lyr.properties['relationships']:
if ("WorkOrders" in rel['name']):
# Initial table from URL of related table to feature layer (in same hosted feature service)
tbl = Table(flc_item.url + r"/" + str(rel['relatedTableId']))
view_item = flc.view_manager.create_join_layer(
join_name=rf"{rel['name']} test joined view",
target_join_fields=["FeatureGUID"],
join=tbl,
join_fields=["GlobalID"],
join_type=JoinType.INNER,
include_geometry=True,
owner=gis.users.me
)
print(rf"Created joined view for relationship: {rel['name']}")Describe the solution you'd like
I would love to see a working example to create a hosted joined view between a feature layer and its related table, so I can better understand how the manager classes are used.
I've run into various errors as I am trying many things here, and am not sure whether I am running into bugs or misunderstandings.
Additional context
Also note that I must use private classes to access the JoinType enumeration.
Activity
astjohn-RM commentedon May 29, 2025
Bump.
Note that there is also a bug here, since I am importing the private JoinType class.
nanaeaubry commentedon Jun 13, 2025
@achapkowski Can you please advise?
astjohn-RM commentedon Jun 16, 2025
@achapkowski Update on my status and some additional observations:
This only works for point feature layers.
The point feature layer-table joins do not include the feature layer fields, only the table's fields.
There is no option for cardinality. Is this assuming/supporting 1:M only?
The documentation of join_fields versus target_join_fields is unclear to me.
Are tables meant to be supported as a target?