Can I get/use the number of related records?

5113
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
AndresCastillo
MVP Regular Contributor

Hi Khaled.

I'm not sure I understand what you replied.

Can you please help me understand?

You say that symbolizing off related tables is possible in AGO.

You mention that ESRI has some examples.

Would you be referring to this?:

https://www.esri.com/arcgis-blog/products/product/mapping/visualizing-related-data-with-join-feature... 

Or do you have other examples?

You also mention that something is not supported in Portal/Server based feature service?

What would be a good solutions moving forward?

 

0 Kudos
DougBrowning
MVP Esteemed Contributor

I forgot to update this until someone hit kudo.  I talked to the field maps team and they know that these relationship values do not work.  They disabled them do to some issues.

They said they would look at reenabling them.  Not sure when.  This post is 2 years old but I talked to them this past summer.

You can now simulate this using the FeatureSet functions now since these are now working in field maps (but still not collector).  But I still think this is weird to have something there that does not work and is not documented anywhere. 

Hope it helps someone.

TravisSizemore
Occasional Contributor

Hi Doug,

Just wondering, have you heard any updates on this? I have a workflow where users create a parent feature when they deploy a device and a related record when they retrieve it. It would be great to have Field Maps calculate the "status" of the parent based on whether a related record exists. This would prevent the most annoying part of the process, which is manually changing the status each time. 

Thanks,

Travis

0 Kudos
DougBrowning
MVP Esteemed Contributor

Yes FeatuteSet functions all work now.  I use this all the time now.   (no the related checkboxes still do not work which is weird so have to do it yourself)

If you are just checking does one exist or not then you can modify this code which is close.

var sql = "PlotID = '" + $feature.PlotID + "'";
var tbl = Filter(FeatureSetByName($map,"Natural and Human Disturbances", ['PlotID'], false), sql);

if (count(tbl) > 1) {
    return "More than one form found"
}
else if (count(tbl) < 1) {
    return "No forms found"
}
else {
    return "1"
}

 Hope that helps

0 Kudos
TravisSizemore
Occasional Contributor

Doug,

Thanks for the suggestion. The code does work within Arcade, but Field Maps doesn't allow it in practice. When I try to create the feature, I get a "Failed to calculate" error under that field. This occurs whether I apply it to a required field or not. I suspect it might be because the Filter function won't work with a null variable (i.e. "record"). Any ideas to get around this?

 

var sql = "deployment_key = '" + $feature.deployment_key + "'";
var record = FeatureSetByName($map,"Active End Deployments", ["Deploy Key (GUID)"], false)
var tbl_cnt = count(Filter(record, sql));


IIf(tbl_cnt == 1, 'retrieved', 'deployed');

 

 

Thanks,

Travis

0 Kudos
TravisSizemore
Occasional Contributor

 

var sql = "deployment_key = '" + $feature.deployment_key + "'";
var record_cnt = count(FeatureSetByName($map,"Active End Deployments", ["Deploy Key (GUID)"], false))


IIf(record_cnt == 1, 'retrieved', 'deployed');

 

 

Actually, when I switched to the above code (removed the Filter), it does allow the calculation in Field Maps when I create the feature, but it doesn't update it when I create the related record, nor does it change if I attempt to edit the parent feature.

 

 

Thanks,

Travis

0 Kudos
DougBrowning
MVP Esteemed Contributor

Are you trying to do this as like an attribute rule or just for display in the popup?  I assumed popup.  Have not used rules much but I would think you would need to test for null.  But then I do not know if it would ever populate after the fact.  Popup should be enough I think?

0 Kudos
TravisSizemore
Occasional Contributor

I was trying to do it as an attribute rule within Field Maps, but maybe if that's not possible I could do something with the popup. The only real use of this field is to change the symbology within the mobile map so they can see where they need to retrieve remaining devices. Perhaps the same expression within the symbology settings would work. 

0 Kudos
DougBrowning
MVP Esteemed Contributor

I was afraid you would say that.  Sorry but cant use FeatureSet functions for symbols.  Too slow I guess.  Pop up only.  It is a huge drawback for sure.  If you want symbols has to be a real field.  Then its back to old school run a script on a schedule.  Not sure this will ever change?  It could be super duper slow.

DougBrowning_0-1654891004029.png

 

0 Kudos
TravisSizemore
Occasional Contributor

Doug,

That's what I suspected, but I figured it was worth asking around to see if anything has changed. Thanks for the info.


Travis

0 Kudos