Can I get/use the number of related records?

5090
19
02-07-2019 10:31 AM
DougBrowning
MVP Esteemed Contributor

In a web map the Attribute table will show you how many related records there are for each Relationship Class. 

Like this

Is there any way I can get\use this number?  Any way to use it to symbolize?  Sort by? 

    For example I want to be able to tell the user they only have 2 LPI forms when it should be 3.  AKA how can the user get a list of features that were not fully completed. 

In Arcade I can do a check using FeatureSetByName but then I again cannot symbolize or filter.  Plus the user would have to click show a thousand times in the attribute table.  (The word Complete is where I clicked)

All of these expressions are also hidden from Ops Dashboard.  They will show in a popup but cannot use for filters or anything like that.  If Ops Dashboard cannot use Arcade can it get this Related records number at all? 

Any other ideas on how to do a dynamic QC to see if the job is complete based on the number of related records?

I know I can run some analysis but that becomes static in time.  Meaning I have to run it on the regular.  It also means a download, run, upload.  I have tried to run analysis directly from the Feature service using a SearchCursor /JSON - and it works great on FCs but on tables it does not work (should but just doesn't).  In this case all the main level relates I am checking are FCs so this may work actually in this case.

Also cannot use the Arcade expression in any of the Analysis tools in AGOL.

thanks a lot

19 Replies
DougBrowning
MVP Esteemed Contributor

Also I can get the relationship count to show up in AGOL but when I try to use this in the new Collector it shows nothing.

Popup in AGOL shows the 0 just fine.  Collector it is just blank.  Even when online.

0 Kudos
KellyGerrow
Esri Frequent Contributor

Hi Doug,

Something to try may be to use Arcade or the join tool.

Visualizing related data with Join Features in ArcGIS Online 

What’s new with Arcade: Taking a stroll through FeatureSets (Part 2) 

If this seems to not be working as expected, try getting in touch with tech support.

-Kelly

DougBrowning
MVP Esteemed Contributor

The second image sample shown is using Arcade.  But it will not let me filter, sort, of even just show the values.  You must click on Show for every single record.

A join would be static so I would have to remake it everyday.

thanks

0 Kudos
KhaledHassen
Esri Contributor

If you really need the count, then you might need to consider calling the feature service layer queryRelated directly and pass returnCountOnly=true. Any other option would be expensive if done in the client side.

This is how the UX is getting the count.

For example:

https://...services/<myService>/FeatureServer/<myLayer>/queryRelatedRecords?relationshipId=0&definit... 

0 Kudos
XanderBakker
Esri Esteemed Contributor

You can use a Field Calculation in ArcGIS Online that retrieves the number of related records and visualize your data on that new field. The downside is that this field will alter your schema and it will be static. So you will have to recalculate the field when the data changes.

0 Kudos
DougBrowning
MVP Esteemed Contributor

Do you know why {relationships/1/objected}  (with Count option) works in AGOL popup but not in Collector?  It works great in a browser but Collector it is just blank. 

Thanks

0 Kudos
DougBrowning
MVP Esteemed Contributor

Checking back in on this one as it has been over a year and a half now.   Is it documented that is broke?  Bug number?

It still does not work.   Also featureset is still not working either.

The other suggestions on here do not work offline.

Got a big project just waiting and waiting on this one.  Also posted here Relationships Counts not displaying in Collector   and similar here  https://community.esri.com/thread/229709-are-the-arcade-featureset-functions-supported-in-collector 

Thanks

0 Kudos
AndresCastillo
MVP Regular Contributor

Hi Doug BrowningKelly Gerrow EmployeeKhaled Hassen EmployeeXander Bakker

In case you might find it useful,

I have come up with a solution to symbolizing from a related table in my post:

Symbolizing Feature Class using related table values

https://community.esri.com/thread/215046-symbolizing-feature-class-using-related-table-values

There is a 17 page word document with details on how to accomplish this.

0 Kudos
KhaledHassen
Esri Contributor

From the online side, database views are also created when joining the source and destination related table in the online view.

This is currently supported when creating online feature service view and we have some examples of how you can do this in online. This is all done using REST API when you add a new join layer to an empty feature service.

BTW, this is not supported in Portal/server based feature service. I would think this is a good solution moving forward if they desire to render data based on joining the source layer and a related table.

Khaled Hassen

Online Feature Service Lead

0 Kudos