Hi there,
I’ve a sample layer and I need to display the related chemical analyses in the popup of a selected sample. That has to be in a table format and I therefore need all fields from my featureSet for my final table.
I managed to fetch the related data but it return the raw data, not using the domain defined for the field “Type”
To use the domain values instead of the raw data and keep all the other fields, the only solution I’ve got is to create a new featureSet and load the data in it.
// Access Ressource data from the Portal
var portal = Portal('https://myserver/portal')
var Chemistry = FeatureSetByPortalItem(portal, '47d3ce362707407bfea6f5424263sdy2',3,['FieldSampleID','Type','Fraction','TiO2_pct'])
// Filter related features by using a common attribute
var FieldSample_ID = $feature.FieldSample_ID
var filterStatement = 'FieldSampleID = @FieldSample_ID'
// Related features as a variable
var relatedData = Filter(Chemistry, filterStatement)
// Definition of the new featureSet
var defFS = {
'geometryType': '',
'fields': [
{'name':'FieldSampleID', 'type':'esriFieldTypeString'},
{'name':'Type', 'type':'esriFieldTypeString'},
{'name':'Fraction', 'type':'esriFieldTypeString'},
{'name':'TiO2_pct', 'type':'esriFieldTypeDouble'}
],
'features': []
}
//Add the original features in the new featureSet definition with domain values
for(var f in relatedData) {
var new_f = {
'attributes': {
'FieldSampleID': f.FieldSampleID,
'Type': DomainName(f, 'Type'),
'Fraction': f.Fraction,
'TiO2_pct': f.TiO2_pct
}
}
Push(defFS.features, new_f)
}
//New featureSet
var newFS = FeatureSet(defFS)
return newFS
That’s quite cumbersome and I wonder if someone would have a simpler solution. Wouldn't it be possible to directly add a field to the first featureSet with the domain values ?
Thanks.
Alex.
Solved! Go to Solution.
I got ma answer from ESRI it's not possible to directly get the domain values when calling the feaureSet. My solution is the most direct one.
That would be good to have a new parameter for the FeatureSetByPortalItem function to get either the raw data or the domains values.
I got ma answer from ESRI it's not possible to directly get the domain values when calling the feaureSet. My solution is the most direct one.
That would be good to have a new parameter for the FeatureSetByPortalItem function to get either the raw data or the domains values.