Include related records in Feature Report

697
7
Jump to solution
01-07-2022 01:44 PM
SFM_TravisBott
Occasional Contributor II

I have a feature service with two related tables. I have surveys that reference all three elements separately (the parent feature service, the 1:1 table and the 1:M table). I would like to be able to run feature reports for one of the related tables, but also include attributes from the related parent record. 

Can this be done directly in the syntax of the feature report template, or does this need to start from data design? In this case my parent feature layer includes jurisdictions and their basic information, and the 1:1 table is a status record. They are linked through globalID, and I didn't think to include some of the basic data already contained in the primary. Can I pull that data through the report template, or should I redesign the table to include it?

1 Solution

Accepted Solutions
ZhifangWang
Esri Regular Contributor

Hi @SFM_TravisBott ,

If I understand correctly, this should be available in the feature report, as long as all layers are in the same service. Using the above example:

  • When you iterating records in a child layer (the current data context is a feature in the child layer), you can reference any attribute/geometry of its parent feature by specifying the parent layer name. For example, 
    • ${#layerB}
      This is an attribute of layerB ${field1inLayerB}
      This is an attribute of its parent feature in layerA ${layerA.field1inLayerA}
      ${/}
  • When you iterating records in the parent layer (the current data context is a feature in the parent layer), you can also access all child features by opening an inner iterations. For example:
    • ${#layerA}
      This is the feature which object ID=${objectid}
      Below are child features in layerC:
      ${#layerC} (this iteration is under the context of the current parent feature)
      child feature, objectid=${oidFieldInLayerC}
      ${/}
      ${/}

 

Please refer to the Repeats section in https://doc.arcgis.com/en/survey123/browser/analyze-results/featurereporttemplates.htm

View solution in original post

0 Kudos
7 Replies
ZhifangWang
Esri Regular Contributor

Hi @SFM_TravisBott 

Would you mind sharing more examples or detailed designs of your layers/stables/surveys?

 

For example, you have 3 tables:

  • Layer A: parent layer, survey A
  • Layer B: child layer (A:B -> 1:1), survey B
  • Layer C: another child layer (A:C -> 1:M), survey C

In a feature report for survey C, you want to reference the parent record in layer A when iterating records in layer C.

 

Does the above example look like what you want?

SFM_TravisBott
Occasional Contributor II

@ZhifangWang You have it correct!

There are two iterations that I would like, in descending order of importance, as the second I can (sort of) already accomplish. Using your examples:

  1. A feature report based on Survey B (1:1 child), that accesses attributes from the parent. 
    1. In my case, the parent is a jurisdiction, and the child record is a long status survey that gets updated bit by bit as they move through an inspection process. When the process is complete, I'd like to be able to produce a written report (done mostly from the child record), but also bring in attributes from the parent record, like jurisdiction name, county, personnel responsible, etc, which are all contained in the parent record. This obviously can be accomplished if I just include those attributes in the child table as well, but that seems redundant. 
  2. A feature report that groups multiple records from Survey C (1:M child), while accessing information from Survey A (parent)
    1. Survey C represents inspection records, and the goal here is to produce reports based on the parent (jurisdiction) that summarize the whole inspection history. In my case this is the easiest to do, as I did not use a GUID to link the records, rather just the name of the jurisdiction, in order to avoid a URL parameter in the mobile app. So I believe I could filter by jurisdiction in the report view on Survey123 and run the report. However, it would be great to be able to work this also as a URL parameter, so field staff could click on their jurisdiction in a map (i.e., the parent record), and produce a report for the whole jurisdiction that accesses both the parent and the collection of child records. 

Can we do it? Do we have the technology?

0 Kudos
ZhifangWang
Esri Regular Contributor

Hi @SFM_TravisBott ,

If I understand correctly, this should be available in the feature report, as long as all layers are in the same service. Using the above example:

  • When you iterating records in a child layer (the current data context is a feature in the child layer), you can reference any attribute/geometry of its parent feature by specifying the parent layer name. For example, 
    • ${#layerB}
      This is an attribute of layerB ${field1inLayerB}
      This is an attribute of its parent feature in layerA ${layerA.field1inLayerA}
      ${/}
  • When you iterating records in the parent layer (the current data context is a feature in the parent layer), you can also access all child features by opening an inner iterations. For example:
    • ${#layerA}
      This is the feature which object ID=${objectid}
      Below are child features in layerC:
      ${#layerC} (this iteration is under the context of the current parent feature)
      child feature, objectid=${oidFieldInLayerC}
      ${/}
      ${/}

 

Please refer to the Repeats section in https://doc.arcgis.com/en/survey123/browser/analyze-results/featurereporttemplates.htm

0 Kudos
SFM_TravisBott
Occasional Contributor II

@ZhifangWang Thank you!

This works perfectly, and I was quickly able to reference those parent records in a feature report. Seems very simple and makes plenty of sense now that I see it, so thank you for getting me there. 

0 Kudos
SFM_TravisBott
Occasional Contributor II

@ZhifangWang - Returning to this after a little bit: Is this workflow still valid?

The documentation hasn't changed, but I've gone to implement this precisely as I had it before but to no avail. I am working with the first example... I am running a report from a 1:1 child record, and trying to reference an attribute in the parent. I cannot seem to access any record in the parent layer. 

SFM_TravisBott_0-1650381446938.png

${City} is definitely a valid field in the parent layer....

SFM_TravisBott_0-1650383606400.png

 

Please let me know if anything has changed on Esri's end that would invalidate this workflow. 

0 Kudos
survey123_solutions
New Contributor III

I have had similar issues and posted a few times on here and there seems to be very little support or responses.  I have 3 posts that have been without a response for the past 2-3 weeks.
Will follow this and see which gets a response first.

0 Kudos
SFM_TravisBott
Occasional Contributor II

Well I'll take heart that you're equally un-answered, but remain demoralized that I can't seem to get this figured out. 

I don't know if it's always been this way but most of the posts I've made over the last few months have gone almost completely unanswered. Between the inconsistent support here and Esri's failure to update or provide accurate documentation at the pace they make changes it's easy to get frustrated. 

0 Kudos