<?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 Re: Create label from the nonNull fields in layer in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/create-label-from-the-nonnull-fields-in-layer/m-p/1580207#M63393</link>
    <description>&lt;P&gt;So I ran it like this and I'm getting nothing in the Console output. What am I missing?&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var pattern = "com"  // Substring to match field names starting with "com"
var result = null
Expects($feature , '*')
for (var field in $feature){
    if (Left(field , Count(pattern)) == pattern &amp;amp;&amp;amp; !IsEmpty($feature[field])) {
        result[field] = $feature[field]
        Console(result)
        Console(field)
        Console(pattern)
    }
}
Console(result)
return Text(result)&lt;/LI-CODE&gt;</description>
    <pubDate>Wed, 29 Jan 2025 22:06:09 GMT</pubDate>
    <dc:creator>LandonHarris</dc:creator>
    <dc:date>2025-01-29T22:06:09Z</dc:date>
    <item>
      <title>Create label from the nonNull fields in layer</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/create-label-from-the-nonnull-fields-in-layer/m-p/1580037#M63373</link>
      <description>&lt;P&gt;I am trying to write an arcade expression to return a list of the fields and values where the value is not null. I am filtering for the field name starting with "com". So far all I get is a blank dictionary. Just to clarify this is to populate a field which I will use to create the label.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var pattern = "com"  // Substring to match field names starting with "com"
var result = {}
for (var field in $feature) {
    if (Left(field, Count(pattern)) == pattern &amp;amp;&amp;amp; !IsEmpty($feature[field])) {
        result[field] = $feature[field]
    }
}
Console(result)
return result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jan 2025 17:28:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/create-label-from-the-nonnull-fields-in-layer/m-p/1580037#M63373</guid>
      <dc:creator>LandonHarris</dc:creator>
      <dc:date>2025-01-29T17:28:58Z</dc:date>
    </item>
    <item>
      <title>Re: Create label from the nonNull fields in layer</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/create-label-from-the-nonnull-fields-in-layer/m-p/1580047#M63376</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/765134"&gt;@LandonHarris&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Are you trying to return the dictionary as a string value or simply return the value. If you are trying to return a dictionary as a string then use the method below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var pattern = "com"  // Substring to match field names starting with "com"
var result = Null
Expects( $feature , '*' )
for (var field in $feature) {
    if (Left( field , Count( pattern ) ) == pattern &amp;amp;&amp;amp; !IsEmpty($feature[field])) {
        result[field] = $feature[field]
    }
}
Console(result)
return Text(result)&lt;/LI-CODE&gt;&lt;P&gt;I believe your expression is also correct but might need to include 'Expects' in order to get all of the fields and values.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jan 2025 17:46:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/create-label-from-the-nonnull-fields-in-layer/m-p/1580047#M63376</guid>
      <dc:creator>RPGIS</dc:creator>
      <dc:date>2025-01-29T17:46:43Z</dc:date>
    </item>
    <item>
      <title>Re: Create label from the nonNull fields in layer</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/create-label-from-the-nonnull-fields-in-layer/m-p/1580048#M63377</link>
      <description>&lt;P&gt;This would give you an empty result if the fields start with a capital "C". "com" is not equivalent to "Com"&lt;/P&gt;&lt;P&gt;Check whether this gives you the result you're expecting&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var pattern = "com"  // Substring to match field names starting with "com"
var result = {}
for (var field in $feature) {
  if (Lower(Left(field, Count(pattern))) == pattern &amp;amp;&amp;amp; !IsEmpty($feature[field])) {
    result[field] = $feature[field]
  }
}
Console(result)
return result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jan 2025 17:47:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/create-label-from-the-nonnull-fields-in-layer/m-p/1580048#M63377</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2025-01-29T17:47:14Z</dc:date>
    </item>
    <item>
      <title>Re: Create label from the nonNull fields in layer</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/create-label-from-the-nonnull-fields-in-layer/m-p/1580077#M63379</link>
      <description>&lt;P&gt;I tried both suggestions but I just get "{}"&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jan 2025 18:04:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/create-label-from-the-nonnull-fields-in-layer/m-p/1580077#M63379</guid>
      <dc:creator>LandonHarris</dc:creator>
      <dc:date>2025-01-29T18:04:07Z</dc:date>
    </item>
    <item>
      <title>Re: Create label from the nonNull fields in layer</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/create-label-from-the-nonnull-fields-in-layer/m-p/1580151#M63386</link>
      <description>&lt;P&gt;The only thing that it could be is that those might field aliases possibly and not actual field names or it might be that your criteria simply does not have a match.&lt;/P&gt;&lt;P&gt;Can you include a screenshot of the fields to see exactly what the issue is. It is hard to troubleshoot exactly when nobody can see what your seeing? It just needs to be a small snippet of the fieldnames.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jan 2025 20:23:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/create-label-from-the-nonnull-fields-in-layer/m-p/1580151#M63386</guid>
      <dc:creator>RPGIS</dc:creator>
      <dc:date>2025-01-29T20:23:14Z</dc:date>
    </item>
    <item>
      <title>Re: Create label from the nonNull fields in layer</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/create-label-from-the-nonnull-fields-in-layer/m-p/1580166#M63387</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LandonHarris_0-1738182951529.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/124310i3F76CA1A2127F657/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LandonHarris_0-1738182951529.png" alt="LandonHarris_0-1738182951529.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jan 2025 20:36:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/create-label-from-the-nonnull-fields-in-layer/m-p/1580166#M63387</guid>
      <dc:creator>LandonHarris</dc:creator>
      <dc:date>2025-01-29T20:36:00Z</dc:date>
    </item>
    <item>
      <title>Re: Create label from the nonNull fields in layer</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/create-label-from-the-nonnull-fields-in-layer/m-p/1580189#M63391</link>
      <description>&lt;P&gt;You mentioned you tried using the 'Expects' as it had been given, and it still returned a blank dictionary.&lt;/P&gt;&lt;P&gt;Can you run your code with console wherever there is a line of code that is running and paste a snippet of the results? You code looks fine, but it is strange that it doesn't return the fields you are looking for.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jan 2025 21:42:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/create-label-from-the-nonnull-fields-in-layer/m-p/1580189#M63391</guid>
      <dc:creator>RPGIS</dc:creator>
      <dc:date>2025-01-29T21:42:45Z</dc:date>
    </item>
    <item>
      <title>Re: Create label from the nonNull fields in layer</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/create-label-from-the-nonnull-fields-in-layer/m-p/1580207#M63393</link>
      <description>&lt;P&gt;So I ran it like this and I'm getting nothing in the Console output. What am I missing?&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var pattern = "com"  // Substring to match field names starting with "com"
var result = null
Expects($feature , '*')
for (var field in $feature){
    if (Left(field , Count(pattern)) == pattern &amp;amp;&amp;amp; !IsEmpty($feature[field])) {
        result[field] = $feature[field]
        Console(result)
        Console(field)
        Console(pattern)
    }
}
Console(result)
return Text(result)&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 29 Jan 2025 22:06:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/create-label-from-the-nonnull-fields-in-layer/m-p/1580207#M63393</guid>
      <dc:creator>LandonHarris</dc:creator>
      <dc:date>2025-01-29T22:06:09Z</dc:date>
    </item>
    <item>
      <title>Re: Create label from the nonNull fields in layer</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/create-label-from-the-nonnull-fields-in-layer/m-p/1580233#M63396</link>
      <description>&lt;P&gt;Put those console lines between lines 4 and 5 so you can see how they're being evaluated for the if statement. Also, initialize "results" as a dictionary, not a null (line 2).&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var pattern = "com"; // Substring to match field names starting with "com"
var result = {};
Expects($feature, "*");
for (var field in $feature) {
  console(Left(field, Count(pattern)), pattern, Left(field, Count(pattern)) == pattern, $feature[field])
  if (Left(field, Count(pattern)) == pattern &amp;amp;&amp;amp; !IsEmpty($feature[field])) {
    result[field] = $feature[field];
  }
}
Console(result);
return Text(result);&lt;/LI-CODE&gt;&lt;P&gt;This is an example of how I tested it in the Playground&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Snag_225a71e.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/124320iC23B5F20DBAA508F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Snag_225a71e.png" alt="Snag_225a71e.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jan 2025 22:31:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/create-label-from-the-nonnull-fields-in-layer/m-p/1580233#M63396</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2025-01-29T22:31:57Z</dc:date>
    </item>
    <item>
      <title>Re: Create label from the nonNull fields in layer</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/create-label-from-the-nonnull-fields-in-layer/m-p/1580355#M63408</link>
      <description>&lt;P&gt;Thanks &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/2839"&gt;@KenBuja&lt;/a&gt;&amp;nbsp;for catching the result = "null" and not dictionary. That was my bad.&lt;/P&gt;&lt;P&gt;I should have wrote it like this.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var pattern = "com"  // Substring to match field names starting with "com"
var result = Null
for (var field in $feature) {
  if (Lower(Left(field, Count(pattern))) == pattern &amp;amp;&amp;amp; !IsEmpty($feature[field])) {
    result = Text(Dictionary( field , $feature[field] ))// Create dictionary and convert to text
  }
}
Console(result)
return result&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 30 Jan 2025 13:12:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/create-label-from-the-nonnull-fields-in-layer/m-p/1580355#M63408</guid>
      <dc:creator>RPGIS</dc:creator>
      <dc:date>2025-01-30T13:12:11Z</dc:date>
    </item>
  </channel>
</rss>

