Adding related table to ArcGIS Online feature layer

69350
73
Jump to solution
01-08-2019 10:26 AM
EricGardecki1
Regular Contributor

I'm trying to figure out how to add a relationship class (related table one-to-many) to a feature layer within AGOL. I do not have ArcGIS Desktop or Server (do have QGIS but I don't think that will help here).

The only info I was able to find led me to believe that it may be possible by editing the service definition JSON but I can't find any reference as to how to edit it to make it work.

What are my options here?

Also, is viewing/editing/adding to related tables supported in AGOL web apps yet (not just Collector)?

Thanks!!

73 Replies
KhaledHassen
Esri Contributor

Looks good to me.

Khaled

0 Kudos
KhaledHassen
Esri Contributor

Eric,

Not sure if you have lots of data in the related table. But if you do, will be good to index the fkey in the related table. try this first:

https://url/ArcGIS/rest/admin/services/<service2>/FeatureServer/<relatedTableId>/addToDefinition

 

Pass the following json:

{

   "indexes" : [

   {

       "name" : "myindex",  // some unique name

       "fields" : "<fkey name in the related table">

  }

]

}

Will be good to have this in your related table. Without indexing the related table foreign key, will get slow query and you might timeout and the results might be flaky like what you see.

Thanks

Khaled

0 Kudos
EricGardecki1
Regular Contributor

I am just testing at this time with sample data. Only 1 record in the related table so not an issue at the moment but good to know. I will try all this out.

0 Kudos
SavannahWinstanley1
Occasional Contributor

I apologize if this is somewhere in this thread already but is there a detailed guide for someone unfamiliar working with REST API on how to use the API in ArcGIS Online to add one feature service as a related feature class to another.

The two services I need to relate are a line feature service and a workforce assignments layer generated from the line feature service: The end goal is to have the line feature layer that is generating the assignments layer relate back to the assignments in workforce so you can see work status for the full feature, and create a kind of "work log" for the line features. If there is a simpler/other workaround for this let me know. 

line feature service:https://services.arcgis.com/hNKc1r3SBL6SVC6I/arcgis/rest/services/Winter_Haven_Street_Sweeping_Miles...  https://services.arcgis.com/hNKc1r3SBL6SVC6I/arcgis/rest/services/assignments_28181aca2529487a976fc8...

assignments service:

https://services.arcgis.com/hNKc1r3SBL6SVC6I/arcgis/rest/services/assignments_28181aca2529487a976fc8... 

I've found the API input below but am unsure how to proceed. I can provide you with the JSON for each feature service mentioned if that's helpful!

Upload Item/Add to Definition API input

Thanks!

0 Kudos
KhaledHassen
Esri Contributor

Hi Savannah,

Updating the item above will not help you and not the right way to do this.

If you need to relate two services, the only way is to create a join view. So you will end up with a view of the two services joined into one layer. I can send you more info about this if this is what you can use. But this is the only way we have currently that joined two separate feature services.

You will need to create an empty feature service view and then add a view layer. I can send you the json you need to use to create the join feature service view.

Thanks

Khaled Hassen

Online FeatureService Dev. Lead

0 Kudos
KevinMacLeodCAI
Frequent Contributor

 

@KhaledHassen  is it possible to create a Relate table as a hosted table on an Organization, if the feature class dataset itself was on another server (on an ArcGIS Enterprise SDE 10.7.1 server)?  For example let's say one entity had an SDE server with some datasets. But, they wanted to collaborate with another agency who has their own AGOL Org. And they wanted the relate tables there on their own Org so they can keep domains updated themselves on a relate table? (With the data living on the separate SDE on agency 1's Enterprise Server)

0 Kudos
KevinMacLeodCAI
Frequent Contributor

@KhaledHassen  greetings, and another question.

1. Is it possible to create a table in ArcGIS Online? (it appears only possible through Pro or ArcMap, which is ok, though it would be nice to be able to simply click "Create" in AGOL, then create a table.)

 

2. Is it possible to create a relate, in ArcGIS Online with this new table? 

 

This is an extremely common question / workflow. For example, I have a layer of street signs. The town has now asked if we can track inspections in ArcGIS Online. So a record of each inspection can be kept. (like how inspection tables are used as digital forms for Collector sometimes) It seems... no?  Since we already created the feature class, but when it was created there was no related table. It seems like either you have to create the related table at the same time, but you can't go back, and create a hosted table (upload a table) and relate it to an existing hosted feature class after the fact?  

And.... I know, I could probably upload the table, make a hosted View then add that to a webmap. But if the feature class was already added to webmaps.. that means redoing the webmaps and all settings, etc. And actually, I don't even know if that would work, since I recall records can't be added to a hosted table. (Is that still the case? This is limiting, and hopefully will be implemented)  So, was just wanting to ask this question to see if maybe now it was possible to create a hosted table and a relate on AGOL now?  Or if not hopefully it can be a Feature Enhancement.  Thank you all for any advice or thoughts. 

0 Kudos
HermanLouie1
Occasional Contributor

I'm in a similar situation where I have 1000's Street Lights (read-only as they are updated every night) and having Painting Records (with pictures) for these points, sometimes with multiple painting records (I'll be uploading historical) 

How to create a RELATIONSHIP CLASS with an AGOL Feature Layer (hosted)?  Any luck?

0 Kudos
JakeNeedle
Regular Contributor

Hi @SavannahWinstanley1 ,

Did you ever get this working with Workforce?  We are trying to do a very similar workflow with the workforce product. Any guidance you can provide would be appreciated.

Jake 

0 Kudos
DavidBuehler
Frequent Contributor

@KhaledHassen -  I have a successfully created the table and relationship, however nothing pushes and/or errors out in Fieldmaps/Collector/Web map.  Cannot see or push to the related table.

Here is the hosted service:

https://services2.arcgis.com/SZYqn7iYnvAZ1Q4U/arcgis/rest/services/rrtestv5/FeatureServer 

I get a service error code 1000 Unable to submit.  Thoughts?

 

0 Kudos