<?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: ArcGIS Dashboards Data expression no longer working get error: Cannot read properties of null (reading 'toString'). Verify test data. in ArcGIS Dashboards Questions</title>
    <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcgis-dashboards-data-expression-no-longer/m-p/1625481#M11228</link>
    <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/803467"&gt;@EmilyLopez&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is more than likely due to a null value being present and .string() attempting to make it a string, which isn't possible in this case, try to add some null checks and you may have some more luck:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var portal = Portal("https://www.arcgis.com");  
var fs = FeatureSetByPortalItem(
    portal,
    "1327308ab2d1487490ec7d5e08fb36ec",
    1,
    ["Species", "Other_Species", "Project_Site", "total_volume_oz", "Size_ac", "Product_Name1", "product_amount_oz1","Product_Name2", 'Surfractant_name', 'surfractant_amount_oz', 'product_amount_oz2'],
    false
);

var sites = Distinct(fs, ["Project_Site"]);
var features = [];

for (var site in sites) {
    var siteName = site["Project_Site"];
    var siteRecords = Filter(fs, "Project_Site = @siteName");

    var totalVol = Sum(siteRecords, "total_volume_oz");
    var totalAc = Sum(siteRecords, "Size_ac");

    // Build unique species list — only distinct values from CSV fields
var speciesSet = {};

for (var rec in siteRecords) {
    var sp1 = rec["Species"];
    var sp2 = rec["Other_Species"];

    if (!IsEmpty(sp1) &amp;amp;&amp;amp; sp1 != null) {
        var parts1 = Split(sp1, ",");
        for (var i = 0; i &amp;lt; Count(parts1); i++) {
            var val = Trim(Replace(parts1[i], "_", " "));
            if (!IsEmpty(val)) {
                speciesSet[val] = true;
            }
        }
    }

    if (!IsEmpty(sp2) &amp;amp;&amp;amp; sp2 != null) {
        var parts2 = Split(sp2, ",");
        for (var j = 0; j &amp;lt; Count(parts2); j++) {
            var val2 = Trim(Replace(parts2[j], "_", " "));
            if (!IsEmpty(val2)) {
                speciesSet[val2] = true;
            }
        }
    }
}


    var speciesList = [];
    for (var k in speciesSet) Push(speciesList, k);
    speciesList = Sort(speciesList);
    var allSpecies = Concatenate(speciesList, ", ");

    // Build unique product list
    var productsSet = Distinct(siteRecords, ["Product_Name1"]);
    var productList = [];
    for (var p in productsSet) {
        var prod = p["Product_Name1"];
        if (!IsEmpty(prod) &amp;amp;&amp;amp; prod != null) Push(productList, Replace(prod, "_", " "));
    }
    var allProducts = Concatenate(productList, ", ");

    Push(features, {
        attributes: {
            Project_Site: siteName,
            total_chemical: totalVol,
            total_ac: totalAc,
            all_species: allSpecies,
            products_used: allProducts
        }
    });
}

// Use Dictionary() directly — this works in popups and Dashboards
var tableDict = {
    fields: [
        { name: "Project_Site", type: "esriFieldTypeString", alias: "Project Site" },
        { name: "total_chemical", type: "esriFieldTypeDouble", alias: "Total Chemical (oz)" },
        { name: "total_ac", type: "esriFieldTypeDouble", alias: "Total Area (ac)" },
        { name: "all_species", type: "esriFieldTypeString", alias: "All Species" },
        { name: "products_used", type: "esriFieldTypeString", alias: "Products Used" }
    ],
    geometryType: "", // no geometry
    features: features
};

// ‌‌ Return as FeatureSet
return FeatureSet(tableDict);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Along with this, try to comment from the top down and use console messages, it may show you where exactly it fails.&lt;/P&gt;&lt;P&gt;Cody&lt;/P&gt;</description>
    <pubDate>Fri, 20 Jun 2025 20:50:50 GMT</pubDate>
    <dc:creator>CodyPatterson</dc:creator>
    <dc:date>2025-06-20T20:50:50Z</dc:date>
    <item>
      <title>ArcGIS Dashboards Data expression no longer working get error: Cannot read properties of null (reading 'toString'). Verify test data.</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcgis-dashboards-data-expression-no-longer/m-p/1625468#M11227</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I made a dashbaord awhile ago with two data expressions that were functioning fine, and now both are giving me the same error "&lt;SPAN&gt;Test execution error: Cannot read properties of null (reading 'toString'). Verify test data."&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If anyone notices something amiss or knows what would have changed to now get an error please let me know!&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var portal = Portal("https://www.arcgis.com");  
var fs = FeatureSetByPortalItem(
    portal,
    "1327308ab2d1487490ec7d5e08fb36ec",
    1,
    ["Species", "Other_Species", "Project_Site", "total_volume_oz", "Size_ac", "Product_Name1", "product_amount_oz1","Product_Name2", 'Surfractant_name', 'surfractant_amount_oz', 'product_amount_oz2'],
    false
);

var sites = Distinct(fs, ["Project_Site"]);
var features = [];

for (var site in sites) {
    var siteName = site["Project_Site"];
    var siteRecords = Filter(fs, "Project_Site = @siteName");

    var totalVol = Sum(siteRecords, "total_volume_oz");
    var totalAc = Sum(siteRecords, "Size_ac");

    // Build unique species list — only distinct values from CSV fields
var speciesSet = {};

for (var rec in siteRecords) {
    var sp1 = rec["Species"];
    var sp2 = rec["Other_Species"];

    if (!IsEmpty(sp1)) {
        var parts1 = Split(sp1, ",");
        for (var i = 0; i &amp;lt; Count(parts1); i++) {
            var val = Trim(Replace(parts1[i], "_", " "));
            if (!IsEmpty(val)) {
                speciesSet[val] = true;
            }
        }
    }

    if (!IsEmpty(sp2)) {
        var parts2 = Split(sp2, ",");
        for (var j = 0; j &amp;lt; Count(parts2); j++) {
            var val2 = Trim(Replace(parts2[j], "_", " "));
            if (!IsEmpty(val2)) {
                speciesSet[val2] = true;
            }
        }
    }
}


    var speciesList = [];
    for (var k in speciesSet) Push(speciesList, k);
    speciesList = Sort(speciesList);
    var allSpecies = Concatenate(speciesList, ", ");

    // Build unique product list
    var productsSet = Distinct(siteRecords, ["Product_Name1"]);
    var productList = [];
    for (var p in productsSet) {
        var prod = p["Product_Name1"];
        if (!IsEmpty(prod)) Push(productList, Replace(prod, "_", " "));
    }
    var allProducts = Concatenate(productList, ", ");

    Push(features, {
        attributes: {
            Project_Site: siteName,
            total_chemical: totalVol,
            total_ac: totalAc,
            all_species: allSpecies,
            products_used: allProducts
        }
    });
}

// Use Dictionary() directly — this works in popups and Dashboards
var tableDict = {
    fields: [
        { name: "Project_Site", type: "esriFieldTypeString", alias: "Project Site" },
        { name: "total_chemical", type: "esriFieldTypeDouble", alias: "Total Chemical (oz)" },
        { name: "total_ac", type: "esriFieldTypeDouble", alias: "Total Area (ac)" },
        { name: "all_species", type: "esriFieldTypeString", alias: "All Species" },
        { name: "products_used", type: "esriFieldTypeString", alias: "Products Used" }
    ],
    geometryType: "", // no geometry
    features: features
};

// ‌‌ Return as FeatureSet
return FeatureSet(tableDict);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jun 2025 20:05:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcgis-dashboards-data-expression-no-longer/m-p/1625468#M11227</guid>
      <dc:creator>EmilyLopez</dc:creator>
      <dc:date>2025-06-20T20:05:47Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Dashboards Data expression no longer working get error: Cannot read properties of null (reading 'toString'). Verify test data.</title>
      <link>https://community.esri.com/t5/arcgis-dashboards-questions/arcgis-dashboards-data-expression-no-longer/m-p/1625481#M11228</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/803467"&gt;@EmilyLopez&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is more than likely due to a null value being present and .string() attempting to make it a string, which isn't possible in this case, try to add some null checks and you may have some more luck:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var portal = Portal("https://www.arcgis.com");  
var fs = FeatureSetByPortalItem(
    portal,
    "1327308ab2d1487490ec7d5e08fb36ec",
    1,
    ["Species", "Other_Species", "Project_Site", "total_volume_oz", "Size_ac", "Product_Name1", "product_amount_oz1","Product_Name2", 'Surfractant_name', 'surfractant_amount_oz', 'product_amount_oz2'],
    false
);

var sites = Distinct(fs, ["Project_Site"]);
var features = [];

for (var site in sites) {
    var siteName = site["Project_Site"];
    var siteRecords = Filter(fs, "Project_Site = @siteName");

    var totalVol = Sum(siteRecords, "total_volume_oz");
    var totalAc = Sum(siteRecords, "Size_ac");

    // Build unique species list — only distinct values from CSV fields
var speciesSet = {};

for (var rec in siteRecords) {
    var sp1 = rec["Species"];
    var sp2 = rec["Other_Species"];

    if (!IsEmpty(sp1) &amp;amp;&amp;amp; sp1 != null) {
        var parts1 = Split(sp1, ",");
        for (var i = 0; i &amp;lt; Count(parts1); i++) {
            var val = Trim(Replace(parts1[i], "_", " "));
            if (!IsEmpty(val)) {
                speciesSet[val] = true;
            }
        }
    }

    if (!IsEmpty(sp2) &amp;amp;&amp;amp; sp2 != null) {
        var parts2 = Split(sp2, ",");
        for (var j = 0; j &amp;lt; Count(parts2); j++) {
            var val2 = Trim(Replace(parts2[j], "_", " "));
            if (!IsEmpty(val2)) {
                speciesSet[val2] = true;
            }
        }
    }
}


    var speciesList = [];
    for (var k in speciesSet) Push(speciesList, k);
    speciesList = Sort(speciesList);
    var allSpecies = Concatenate(speciesList, ", ");

    // Build unique product list
    var productsSet = Distinct(siteRecords, ["Product_Name1"]);
    var productList = [];
    for (var p in productsSet) {
        var prod = p["Product_Name1"];
        if (!IsEmpty(prod) &amp;amp;&amp;amp; prod != null) Push(productList, Replace(prod, "_", " "));
    }
    var allProducts = Concatenate(productList, ", ");

    Push(features, {
        attributes: {
            Project_Site: siteName,
            total_chemical: totalVol,
            total_ac: totalAc,
            all_species: allSpecies,
            products_used: allProducts
        }
    });
}

// Use Dictionary() directly — this works in popups and Dashboards
var tableDict = {
    fields: [
        { name: "Project_Site", type: "esriFieldTypeString", alias: "Project Site" },
        { name: "total_chemical", type: "esriFieldTypeDouble", alias: "Total Chemical (oz)" },
        { name: "total_ac", type: "esriFieldTypeDouble", alias: "Total Area (ac)" },
        { name: "all_species", type: "esriFieldTypeString", alias: "All Species" },
        { name: "products_used", type: "esriFieldTypeString", alias: "Products Used" }
    ],
    geometryType: "", // no geometry
    features: features
};

// ‌‌ Return as FeatureSet
return FeatureSet(tableDict);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Along with this, try to comment from the top down and use console messages, it may show you where exactly it fails.&lt;/P&gt;&lt;P&gt;Cody&lt;/P&gt;</description>
      <pubDate>Fri, 20 Jun 2025 20:50:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-dashboards-questions/arcgis-dashboards-data-expression-no-longer/m-p/1625481#M11228</guid>
      <dc:creator>CodyPatterson</dc:creator>
      <dc:date>2025-06-20T20:50:50Z</dc:date>
    </item>
  </channel>
</rss>

