Tables and Relationships

705
2
Jump to solution
10-12-2020 04:14 PM
KenBuja
MVP Honored Contributor

I have a feature service that contains a feature layer ("Management Regions") and several tables. The layer has a M:M relationship with Table 1 ("Source"), and that table has M:M relationships with the other tables.

When I add the layer as a FeatureLayer, I can see the Source relate using the relationships property. However, if I add the table as a FeatureLayer, its relationships property is null. Is there a way to get the relationships for the table?

  const regionLayer = new FeatureLayer({
    url: 'https://services2.arcgis.com/blah/FeatureServer/0',
    outFields: ['*']
  });
  const sourceTable = new FeatureLayer({
    url: 'https://services2.arcgis.com/blah/FeatureServer/1',
    outFields: ['*']
  });
0 Kudos
1 Solution

Accepted Solutions
UndralBatsukh
Esri Regular Contributor

Hi there, 

Are you loading your non-spatial table? 

Non-spatial table instance can be created from the table url in a service and the table must be loaded by calling load() method.

// Add a non-spatial table.require(["esri/layers/FeatureLayer"], function(FeatureLayer){   // points to the non-spatial table in a service storing San Francisco crime incidents.  const table = new FeatureLayer({     url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/SF311/FeatureServer/1"  });   table.load().then(function() {      // table is loaded. ready to be queried on the server.  }); });

Here is a doc: FeatureLayer | ArcGIS API for JavaScript 4.17 

View solution in original post

2 Replies
UndralBatsukh
Esri Regular Contributor

Hi there, 

Are you loading your non-spatial table? 

Non-spatial table instance can be created from the table url in a service and the table must be loaded by calling load() method.

// Add a non-spatial table.require(["esri/layers/FeatureLayer"], function(FeatureLayer){   // points to the non-spatial table in a service storing San Francisco crime incidents.  const table = new FeatureLayer({     url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/SF311/FeatureServer/1"  });   table.load().then(function() {      // table is loaded. ready to be queried on the server.  }); });

Here is a doc: FeatureLayer | ArcGIS API for JavaScript 4.17 

KenBuja
MVP Honored Contributor

Loading the table was the step I missed.

0 Kudos