<?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>idea Arcade Form Calculation return Dictionary in ArcGIS Field Maps Ideas</title>
    <link>https://community.esri.com/t5/arcgis-field-maps-ideas/arcade-form-calculation-return-dictionary/idi-p/1194882</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Arcade&amp;nbsp;Form Calculation profile return types are:&amp;nbsp;Date | Number | Text. It will be helpful to also return a Dictionary type. This could be used for ArcGIS Runtime apps, in case a few attributes can be calculate in the same expression.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 22 Jul 2022 12:50:26 GMT</pubDate>
    <dc:creator>ManoSadeh</dc:creator>
    <dc:date>2022-07-22T12:50:26Z</dc:date>
    <item>
      <title>Arcade Form Calculation return Dictionary</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-ideas/arcade-form-calculation-return-dictionary/idi-p/1194882</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Arcade&amp;nbsp;Form Calculation profile return types are:&amp;nbsp;Date | Number | Text. It will be helpful to also return a Dictionary type. This could be used for ArcGIS Runtime apps, in case a few attributes can be calculate in the same expression.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jul 2022 12:50:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-ideas/arcade-form-calculation-return-dictionary/idi-p/1194882</guid>
      <dc:creator>ManoSadeh</dc:creator>
      <dc:date>2022-07-22T12:50:26Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Form Calculation return Dictionary</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-ideas/arcade-form-calculation-return-dictionary/idc-p/1229032#M923</link>
      <description>&lt;P&gt;I had this same thought about being able to return more complex objects (dict, feature, geometry, etc.), but it might be weird to have a dictionary return type without a matching dictionary field type.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Arcade supports returning a JSONified string and then a way to read it in as a dict with the fromJSON() function.&amp;nbsp; I use this approach a lot when fetching data from other layers as using featureSetByAnything can be very costly, so if I need multiple fields to fetch data from the same dataset or feature I just delegate the task to a single field that returns a jsonified string and use the result of that field as an in memory lookup resource.&lt;BR /&gt;&lt;BR /&gt;Building it looks like this...&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;//ASSIGNED TO
//  $feature["rsrc_service_info"]

function getServiceInfo() {
    var serviceNumber = $feature["service_number"];
    var serviceNumberDesc = DomainName($feature,"service_number");
    // var serviceNumber = "'02081600.1658"; // TEST VALUE
    // var serviceNumberDesc = "'02081600.1658 (Placeholder)"; // TEST VALUE
    
    if (!IsEmpty(serviceNumber) &amp;amp;&amp;amp; 
        Find('Placeholder', serviceNumberDesc, 0) == -1) {
            
        serviceNumber = Replace(serviceNumber, "'", "");
        var sql = "service_number LIKE '%" + serviceNumber + "'"
        var fields = ['service_number', 'service_status', 'task_id', 
                      'keyword_id', 'permit_id'];
        var mapLayer = 'Service_Orders_Resource_Table'
        var fset = FeatureSetByName($map, mapLayer, fields, false);
        var ffset = Filter(fset, sql);
        for (var f in ffset) {
            break;
        }
        
        if (!IsEmpty(f)) {
            console('Building jsonText');
            json = '{"service_number": "' + f.service_number + '", ' 
                  + '"service_status": ' + IIF(IsEmpty(f.service_status), 'null', '"' + f.service_status) + '", '
                  + '"task_id": ' + IIF(IsEmpty(f.task_id), 'null', f.task_id) + ', ' 
                  + '"keyword_id": ' + IIF(IsEmpty(f.keyword_id), 'null', f.keyword_id) + ', ' 
                  + '"permit_id": ' + IIF(IsEmpty(f.permit_id), 'null', f.permit_id) + '' 
                  + '}';
            console('JSON Length: ' + Count(json));
            console(json);
        };
    } else {
        console(pad + 'Service Number is null or placeholder; return empty json');
    };
    
    return json;
};


//START HERE
var pad = '&amp;gt;&amp;gt;&amp;gt; ';
var json = '{}';

return getServiceInfo()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And utilizing it looks like...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;//ASSIGNED TO
//  $feature["service_keyword"]

console('Set Service Keyword')
var pad  = '&amp;gt;&amp;gt;&amp;gt; '

var key = 'keyword_id'
var value = Null;

var json = $feature["rsrc_service_info"];
// var json = '{"service_number": "02081600.1658", "keyword_id": 83880}'; // TEST VALUE

if (!IsEmpty(json) &amp;amp;&amp;amp; json != '{}' &amp;amp;&amp;amp; Find(key, json, 0) != -1) {
    var dict = fromJSON(json)
    value = dict.keyword_id
};
console(pad + key + ': ' + value)
return value;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 06 Nov 2022 20:57:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-ideas/arcade-form-calculation-return-dictionary/idc-p/1229032#M923</guid>
      <dc:creator>JustinReynolds</dc:creator>
      <dc:date>2022-11-06T20:57:22Z</dc:date>
    </item>
  </channel>
</rss>

