AnsweredAssumed Answered

JoinData in JavaScript from Feature Layer in GPServer to SQL Table

Question asked by mkoneya on Oct 5, 2017

I have a Geoprocessing Server that creates stops and routes from an input of point features.   The GP Server uses a Map Service to display the results.    I am able to get the stops added as a Feature Layer from the GP Server's map service and view attributes and add graphics from the stops.


What I would like to do is to join that Stops Feature Layer to a SQL table in a Map Service that has a Dynamic Workspace so that additional information on the stops can be viewed.


I followed an example from GitHub,  developer-support/joinDataSource_show_All_data_fromDataGrid.html at master · Esri/developer-support · GitHub  but am not able to view the joined FeatureLayer's attributes.    It does not look like any features are added,  but it does look like the FeatureLayer is being created as I don't get any errors but something is not right because after loading the layer,  I am trying to view the attributes but it shows no graphics.


Am I not applying the JoinData properly?   Is it possible to join from my GP Server Feature Layer to a SQL Table from a dynamic workspace in another layer?


Thanks for any help solving this issue.




function showStopResults(results) {
//define the layer's data source from a table
var rightTableSource = new LayerDataSource();
rightTableSource.dataSource = new TableDataSource({
workspaceId: "FireInspectWorkspaceID",
dataSourceName: "FireInspect.dbo.viewMapScheduledInspections"

//point to the joined Table related to specific FeatureLayer ID
var leftTableSource = new LayerMapSource({
mapLayerId: 1
//create a layerDataSource to storage on the fly "join" data
var joinDataSource = new JoinDataSource({
joinType: "left-outer-join",
leftTableKey: "Name",
rightTableKey: "FireInspect.dbo.viewMapScheduledInspections.ID_String",
leftTableSource: leftTableSource,
rightTableSource: rightTableSource

//query the feature layer with layerDataSource and list out all data in grid
var layerDataSource = new LayerDataSource();
layerDataSource.dataSource = joinDataSource;
joinFeatureLayer = new FeatureLayer("http://vmascesri01:6080/arcgis/rest/services/Fire/FireInspections/MapServer/dynamicLayer", {
mode: FeatureLayer.MODE_ONDEMAND,
outFields: ["*"],
source: layerDataSource,
id: "datalayer"

//This function works with an array of FindResult that the task returns

on(joinFeatureLayer, "load", function(evt)
//create array of attributes
var items =, function (result) {
var graphic = result.feature;
return result.feature.attributes;