Views with new Cases fields

574
13
Jump to solution
03-19-2020 08:17 AM
Labels (1)
Highlighted
Occasional Contributor II

In the Coronavirus Response solution, if I add custom fields to the Cases feature layer, do I have to recreate the three feature layer views from scratch?  It does not seem you can update the views with new fields on the source feature layer.

1 Solution

Accepted Solutions
Highlighted
Esri Contributor

Summarizing in one comment. Hopefully that's useful!

When adding a new field to the Cases feature layer the new field will need to be accounted for on the views created from the Cases feature layer. Getting the new field on the view depends on the type view:

Cases_public is just a basic view of Cases with editing turned off in Settings (used in the Community Impact Dashboard)

Cases_reporter - as above but with editing turned on (used by the Case Reporter survey)

Cases_current - a join view returning the most recent report for a reporting area. 

A new field can be exposed on the existing Cases_public and Cases_reporter views, whereas Cases_current needs to be recreated. Let's look at exposing first:

In all likelihood a new field will be added to the Cases table which means the method of defining the fields exposed to the view using Visualization tab on the item page will not work. However, we can add the table to a map to set the view definition:

  1. Add a new field to the Cases table in the Cases feature layer.
  2. Navigate to the Cases_public or Cases_reporter view in your contents.
  3. Click the Open in Map View down arrow, then Add to new map.
  4. Click the More Options ellipses on the Cases, then click Set View Definition. Click Define Fields.
  5. Scroll to the newly created field, check the box. Click Apply. The new field is added to the view’s definition.

To get that new field on Cases_current it will need to be recreated:

  1. Add the Cases feature layer to a new web map.
  2. Click Analysis, Summarize Data, Join Features.
  3. Configure the join in this way (Note on naming the new view: to name the new view Cases_current, the existing join view would need to be deleted. However because of subsequent steps, it would be advantageous to leave the current Cases_current view in place and use a new name):
    1. Name:

      Cases_current or something similar. 

      Target:

      Reporting Areas

      Layer to join to the target layer:

      Cases

      Fields to match:

      name = name

      Join Operation:

      Join one to one

      Define which record is kept:

      Order by Date Reported / Sort by Newest

  4. Update the Community Impact Dashboard indicators and selector dropdown to use the new join view. This will require reconfiguring some of the dashboard elements. Because of this, a good workflow is leaving the existing Cases_current view in place, save a copy of the dashboard for configuration reference, update the original dashboard to use the new view. 

Mike

View solution in original post

13 Replies
Highlighted
Occasional Contributor

I'm dealing with this today as well.  From what little I know about hosted layer views, you cannot alter the schema of the view to include new fields from the source layers, so you have to recreate them all.  To make it more complex, the 'Cases Current' hosted view does some aggregation from the cases table to the related boundaries layer, so that you have one table with the most recent counts for each boundary.  The view was created by Esri's solution so I don't know you can see the code for how the join is done, let alone recreate it.

Hoping to get some answers this afternoon.  I'll share here if I find out some tricks

-Andrew

Reply
0 Kudos
Highlighted
Occasional Contributor

I just heard back from Esri:

To [re]create the [Cases Current] view add the Cases feature service to the map viewer. From Analysis open the Join Features tool. Configure your settings for the join and at the bottom check the option to save the output as a hosted view.

 

To define the join you will do a 1:1 attribute join based on the name field, and sort on the Report Date field in descending order.

You still have to manually recreate all the views, but I hope that helps. 

-Andrew

Highlighted
Occasional Contributor II

Thanks Andrew!  I'm going to try to summarize.  The Cases hosted feature layer has three views defined on it:

Cases_public is just a basic view of Cases with editing turned off in Settings.  You can recreate it with the Create View Layer button and don't need to change the View Definition.

Cases_reporter - as above but with editing turned on.

Cases_current - as you describe above, recreate in Map Viewer with a join.  It seems that target layer is "Cases", layer to join is "Cases - Cases", match fields where name = name, join one to one, order by Date Reported is Newest, save as a feature layer view.

You have to edit the Case Reporter form in Survey123 Connect.  Add your new field names on the first sheet (don't forget the esriFieldType), and change the id in the submission_url in the Settings sheet.

Then you need to replace the Active Cases layer in the Community Impact Dashboard map with your new Cases_current view (might want to update the URL of the service using ArcGIS Online Assistant).

Then you might want to reconfigure the "Community Impact Dashboard" dashboard.

I think I have that right.

Highlighted
Esri Contributor

Nice explanation, Kevin Mayall‌! I think you have it right, too. 

Highlighted
Esri Contributor

I'll just add you can also expose your new field to the existing Cases_public and Cases_reporter views by updating their view definition.

Highlighted
Occasional Contributor II

I tried to do that but they did not seem to have the Set View Definition option under the Visualization tab on the item page.

Reply
0 Kudos
Highlighted
Esri Contributor

You can add the view to a web map and access Set View Definition that way as well. 

Highlighted
New Contributor III

This worked with perfectly with both cases_public and cases_reporter views. Why won't cases_current allow that?

Reply
0 Kudos
Highlighted
Esri Contributor

Cases_current is a hosted join view and unfortunately there is no way to expose a new field added to one of the join view's sources. So that view would need to be recreated to pick up a new field. Andrew outlined that process well above:

To [re]create the [Cases Current] view add the Cases feature service to the map viewer. From Analysis open the Join Features tool. Configure your settings for the join and at the bottom check the option to save the output as a hosted view.

 

To define the join you will do a 1:1 attribute join based on the name field, and sort on the Report Date field in descending order.

Reply
0 Kudos