<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Returned FeatureSet from data expression with domain relation? in ArcGIS Dashboards Questions</title>
    <link>https://community.esri.com/t5/arcgis-dashboards-questions/returned-featureset-from-data-expression-with/m-p/1096298#M5044</link>
    <description>&lt;P&gt;Dear Community,&lt;/P&gt;&lt;P&gt;I am playing around with the ArcGIS Dashboard and the data expression functionality ...&lt;/P&gt;&lt;P&gt;Now I am created a new FeatureSet using data expressions from an Layer with relation to a domain.&lt;/P&gt;&lt;P&gt;If I am presenting this FeatureSet in a list widget only the numeric values are presented and not the corresping domain values.&lt;/P&gt;&lt;P&gt;Is there a way to apply this domain to the new FeatureSet or any other recommended way?&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Daniel.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 08 Sep 2021 11:36:13 GMT</pubDate>
    <dc:creator>dstrigl</dc:creator>
    <dc:date>2021-09-08T11:36:13Z</dc:date>
    <item>
      <title>Returned FeatureSet from data expression with domain relation?</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/returned-featureset-from-data-expression-with/m-p/1096298#M5044</link>
      <description>&lt;P&gt;Dear Community,&lt;/P&gt;&lt;P&gt;I am playing around with the ArcGIS Dashboard and the data expression functionality ...&lt;/P&gt;&lt;P&gt;Now I am created a new FeatureSet using data expressions from an Layer with relation to a domain.&lt;/P&gt;&lt;P&gt;If I am presenting this FeatureSet in a list widget only the numeric values are presented and not the corresping domain values.&lt;/P&gt;&lt;P&gt;Is there a way to apply this domain to the new FeatureSet or any other recommended way?&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Daniel.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Sep 2021 11:36:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/returned-featureset-from-data-expression-with/m-p/1096298#M5044</guid>
      <dc:creator>dstrigl</dc:creator>
      <dc:date>2021-09-08T11:36:13Z</dc:date>
    </item>
    <item>
      <title>Re: Returned FeatureSet from data expression with domain relation?</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/returned-featureset-from-data-expression-with/m-p/1096353#M5049</link>
      <description>&lt;H3&gt;Other Recommended Way&lt;/H3&gt;&lt;P&gt;There is a way of applying the domain to another object, but since you're working directly with the layer, it would be easier to use &lt;A href="https://developers.arcgis.com/arcade/function-reference/data_functions/#domainname" target="_blank" rel="noopener"&gt;DomainName&lt;/A&gt; while building your FeatureSet. I imagine you're iterating through the layer and populated the FeatureSet's &lt;STRONG&gt;Features&lt;/STRONG&gt; array, so it might look like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Assuming vars 'lyr' and 'out_dict' represent your input layer and output dictionary which will be converted to a FeatureSet, respectively

var i = 0

for(var l in lyr){
    out_dict['features'][i] = {attributes: {'domain_field': DomainName(l, 'domain_field')}}
    i ++
}

fs = FeatureSet(Text(out_dict))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;H3&gt;Applying a Domain to a FeatureSet&lt;/H3&gt;&lt;P&gt;See the Arcade function &lt;A href="https://developers.arcgis.com/arcade/function-reference/data_functions/#domain" target="_blank" rel="noopener"&gt;Domain&lt;/A&gt;. If you use this on your layer first, it returns a dictionary representing the domain for a given field. The example on the linked page looks like this:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class="hljs-comment"&gt;{&lt;/SPAN&gt;
&lt;SPAN class="hljs-comment"&gt;  type: "codedValue" ,&lt;/SPAN&gt;
&lt;SPAN class="hljs-comment"&gt;  name: "poleTypes",&lt;/SPAN&gt;
&lt;SPAN class="hljs-comment"&gt;  dataType: "number",&lt;/SPAN&gt;
&lt;SPAN class="hljs-comment"&gt;  codedValues: [&lt;/SPAN&gt;
&lt;SPAN class="hljs-comment"&gt;    { name: "Unknown", code: 0 },&lt;/SPAN&gt;
&lt;SPAN class="hljs-comment"&gt;    { name: "Wood", code: 1 },&lt;/SPAN&gt;
&lt;SPAN class="hljs-comment"&gt;    { name: "Steel", code: 2 }&lt;/SPAN&gt;
&lt;SPAN class="hljs-comment"&gt;  ]&lt;/SPAN&gt;
&lt;SPAN class="hljs-comment"&gt;}&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;When creating the FeatureSet (or rather, the dictionary that will become your FeatureSet), you establish the &lt;STRONG&gt;fields&lt;/STRONG&gt; array. Within a given field, you can simply append the domain returned from this function, as the &lt;STRONG&gt;domain&lt;/STRONG&gt; is a &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Field.html" target="_self"&gt;property of a field.&lt;/A&gt; This can be done &lt;EM&gt;before&lt;/EM&gt; populating the features.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// Assuming var 'lyr' is your input layer

var dom = Domain(lyr, 'domain_field')

var out_dict = {
    'fields': [{
        'name': 'domain_field',
        'type': 'esriFieldTypeInteger',
        'domain': dom
    }],
    'geometryType': '',
    'features': []
}

// Populate your FeatureSet as usual, domain should apply&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Sep 2021 13:34:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/returned-featureset-from-data-expression-with/m-p/1096353#M5049</guid>
      <dc:creator>jcarlson</dc:creator>
      <dc:date>2021-09-08T13:34:08Z</dc:date>
    </item>
    <item>
      <title>Re: Returned FeatureSet from data expression with domain relation?</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/returned-featureset-from-data-expression-with/m-p/1096640#M5054</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/363906"&gt;@jcarlson&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;thanks a lot for your help.&lt;/P&gt;&lt;P&gt;The way with the &lt;FONT face="courier new,courier"&gt;DomainName()&lt;/FONT&gt; function is exactly what I am trying now:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var portal = Portal('https://www.arcgis.com');
var itemId = '???';
var layerId = 1;

var fs = GroupBy(
    Filter(
        FeatureSetByPortalItem(portal, itemId, layerId, ['ACCOUNT_MANAGER', 'REGION'], false),
        'ACCOUNT_MANAGER &amp;gt; 0'),
    ['ACCOUNT_MANAGER'],
    [
        { name: 'COUNT_REGIONS', expression: 'REGION', statistic: 'COUNT' },
    ]);

var dict = {
    'fields': [
        { 'name': 'ACCOUNT_MANAGER', 'type': 'esriFieldTypeString' },
        { 'name': 'COUNT_REGIONS', 'type': 'esriFieldTypeInteger' },
    ],
    'geometryType': '',
    'features': []
    };

var index = 0;
for (var f in fs) {
    dict.features[index] = {
        'attributes': {
            'ACCOUNT_MANAGER': DomainName(f, 'ACCOUNT_MANAGER'),
            'COUNT_REGIONS': f['COUNT_REGIONS'],
        },
    };
    index++;
}

return FeatureSet(Text(dict));&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But this seems to doesn't work in my sample &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Additionally I tested the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var fs = FeatureSetByPortalItem(...);
Console("ACCOUNT_MANAGER:");
for (var f in fs) {
    var d = DomainName(f, "ACCOUNT_MANAGER");
    Console(d);
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and&amp;nbsp;I only get the numeric values and NOT the names represented by the domain!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markdown"&gt;ACCOUNT_MANAGER:
4
2
2
4
4
.
.
.&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you have any idea what's wrong?&lt;/P&gt;&lt;P&gt;The names are still in the layer, because if I open the table inside the Map Viewer I will see it ...&lt;/P&gt;&lt;P&gt;Some note: Could it be a problem that the table which includes the&amp;nbsp; ACCOUNT_MANAGER has a subtype?&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Daniel.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Sep 2021 07:08:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/returned-featureset-from-data-expression-with/m-p/1096640#M5054</guid>
      <dc:creator>dstrigl</dc:creator>
      <dc:date>2021-09-09T07:08:53Z</dc:date>
    </item>
    <item>
      <title>Re: Returned FeatureSet from data expression with domain relation?</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/returned-featureset-from-data-expression-with/m-p/1376563#M9008</link>
      <description>&lt;P&gt;I know this is an old thread but I had the same problem. The field which had a domain is type&amp;nbsp;&lt;SPAN&gt;"esriFieldTypeInteger" (names are strings and codes are integers). So what I ended up doing was create a new "esriFieldTypeString" field with arcade and pushing the DomainName to that field.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;So basically, in a loop where l is the iteration in layer: (dictionary(l)).attributes["new_field"] = domainname(l, "domain_field").&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 Jan 2024 17:01:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/returned-featureset-from-data-expression-with/m-p/1376563#M9008</guid>
      <dc:creator>mikaël</dc:creator>
      <dc:date>2024-01-31T17:01:14Z</dc:date>
    </item>
  </channel>
</rss>

