ArcGIS Web AppBuilder – Using Field from Another Table in Popup

arcgis-javascript-apiarcgis-web-appbuilderinfowindowpopup

I have an Web AppBuilder application, in popup windows it shows up to 10 fields.

For one field of it, can I get a value from another service/SQL table by customizing application.

I tried to customize it in Visual Studio, but the solution didn't support due to HTTP/HTTPS errors.

For example actual popup window as "ID1" field from "table1" and by customizing I want to change it like:

SELECT ID2 FROM table2 WHERE ID1='@ID1'"

Get the "ID2" value from "table2" and display it in popup when opened instead of displaying "ID1".

Best Answer

Since you're using WAB, I guess you have a WebMap. Then you can customize the Popup directly in your WebMap using Arcade and get information from a related table using a custom attribute expression.

Here general info about customizing your Popup using arcade

Here you have info about getting info from another layers

You're attribute expression would be something like this:

// first read out the ID of the Feature1
var id = $feature["ID1"];
// access the table Feature2
var tbl = FeatureSetByName($map, 'Feature2');
// create a sql expression to query on ID
var sql = "ID1 = '" + ID + "'";
// filter the table using the sql expression
var related_data = Filter(tbl, sql);
// count the resulting records
var cnt = Count(related_data);

// initiate a variable to hold the result
var result = 0;

// check if there are related records found for the current ID
if (cnt == 1) {
   // loop through related records
   for (var row in related_data) {
       // read the ID2 from the related data
       result = row.ID2;
   }
} else {
   result = "Not possible to get related records";
}
// return the result
return result;
Related Question