Getting a popup to work with related tables

773
4
12-20-2017 11:10 AM
CynthiaKozma
Occasional Contributor II

This is my first attempt at a Javascript app, so I am very new at this.  We are trying to upgrade an old MapObjects site that sees a lot of traffic.  Mainly, people click on a parcel and it shows them all the information about that parcel.  There are several tables that are linked to the parcel layer.  I have tried creating a Map Service (hosted on our server) that has the parcel layer with a relationship class to the tables, and I have also tried creating a feature layer (hosted on AGOL) that is created from the parcels with those same relationship classes.  Neither of these have worked.  I may not have set these up correctly either.  If I point the url to a parcel layer with no related tables, it works.  As soon as I change that url to the map service or the feature layer with related tables, nothing shows in the popup.  What is the best way to go about getting a popup with related tables?  Any help is appreciated.

var parcels = new FeatureLayer({
          url: "https://services3.arcgis.com/XXXXXXXXXXXXXX/arcgis/rest/services/Parcels/FeatureServer",
          id: "taxlots",
          outFields: ["*"],
          popupTemplate: { // autocasts as new PopupTemplate()
           title: "Parcel Number: ",
           content: [{
               type: "fields",
               fieldInfos: [{
              fieldName: "ASSESSOR_N",
              visible: true,
              label: "Assessor Number"
            }, {
              fieldName: "relationships/0/FIRST_NAME",
              visible: true,
              label: "First Name"
            }, {
              fieldName: "relationships/0/LAST_NAME",
              visible: true,
              label: "Last Name"
            }]
           }]
           },
     });
0 Kudos
4 Replies
RobertScheitlin__GISP
MVP Emeritus

Cynthia,

   A FeatureLayer has to have a layer id number at the end of the url.

https://services.arcgis.com/V6ZHFr6zdgNZuVG0/ArcGIS/rest/services/Beverly%20Hills%20Trees%20By%20Blo...

Yours above does not.

0 Kudos
CynthiaKozma
Occasional Contributor II

Yes, you are right.  My updated version does have a /0 at the end, but there is still something about the related tables that it does not like.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Cynthia,

   You have compared you code to this sample right?

Popup with related fields | ArcGIS API for JavaScript 3.23 

0 Kudos
CynthiaKozma
Occasional Contributor II

An updated version of it, yes.  It is where I initially grabbed the code.  I'll try looking through it again.

0 Kudos