<?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: Arcade Expression for Barcode Scanning Verification in ArcGIS Field Maps Questions</title>
    <link>https://community.esri.com/t5/arcgis-field-maps-questions/arcade-expression-for-barcode-scanning/m-p/1624920#M10979</link>
    <description>&lt;P&gt;Thank you so much! I was pulling my hair out wondering what was wrong.&lt;/P&gt;&lt;P&gt;I understand why you changed the script to string instead of text as text isnt truly an acceptable field type that ESRI uses.&lt;/P&gt;&lt;P&gt;However how did you also know length was not the right function to use?&lt;/P&gt;</description>
    <pubDate>Thu, 19 Jun 2025 04:15:54 GMT</pubDate>
    <dc:creator>RangerofGIS</dc:creator>
    <dc:date>2025-06-19T04:15:54Z</dc:date>
    <item>
      <title>Arcade Expression for Barcode Scanning Verification</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/arcade-expression-for-barcode-scanning/m-p/1624536#M10965</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm trying to get the following arcade expression to work. Essentially the app is designed to scan bins, however sometimes the wrong bin gets scanned so I'm trying to implement a validation check so that only certain bin prefixes are allowed to be scanned and submitting but I'm getting the following message when I use this expression&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class=""&gt;boolean:&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;false&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;the console also throws out&lt;/P&gt;&lt;P&gt;Failed: Empty or non-text&lt;/P&gt;&lt;P&gt;Result: false&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;// barcode variable from feature attribute&lt;BR /&gt;var barcodeValue = 'BTR7981006';&lt;BR /&gt;Console('Barcode Value: ' + barcodeValue);&lt;/P&gt;&lt;P&gt;// Define valid prefixes for Bin&lt;BR /&gt;var validPrefixes = [&lt;BR /&gt;'BTR75', 'BTR76', 'BTR780', 'BTR781', 'BTR7820', 'BTR7821', 'BTR7831',&lt;BR /&gt;'BTR7846', 'BTR7847', 'BTR7848', 'BTR7855', 'BTR7866', 'BTR789', 'BTR790',&lt;BR /&gt;'BTR792', 'BTR798'&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;var isValid = false;&lt;/P&gt;&lt;P&gt;// Check if barcode is empty or not a text value&lt;BR /&gt;if (IsEmpty(barcodeValue) || TypeOf(barcodeValue) != 'Text') {&lt;BR /&gt;Console('Failed: Empty or non-text');&lt;BR /&gt;isValid = false;&lt;BR /&gt;}&lt;BR /&gt;// Check if barcode starts with BTR and is 10 characters long&lt;BR /&gt;else if (Left(barcodeValue, 3) != 'BTR' || Length(barcodeValue) != 10) {&lt;BR /&gt;Console('Failed: Invalid format, BTR=' + Left(barcodeValue, 3) + ', Length=' + Text(Length(barcodeValue)));&lt;BR /&gt;isValid = false;&lt;BR /&gt;}&lt;BR /&gt;// Check if barcode starts with any valid prefix&lt;BR /&gt;else {&lt;BR /&gt;for (var prefixIndex in validPrefixes) {&lt;BR /&gt;var currentPrefix = validPrefixes[prefixIndex];&lt;BR /&gt;if (Left(barcodeValue, Length(currentPrefix)) == currentPrefix) {&lt;BR /&gt;Console('Passed: Matched prefix ' + currentPrefix);&lt;BR /&gt;isValid = true;&lt;BR /&gt;break;&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// Return validation result&lt;BR /&gt;Console('Result: ' + Text(isValid));&lt;BR /&gt;return isValid;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jun 2025 01:35:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/arcade-expression-for-barcode-scanning/m-p/1624536#M10965</guid>
      <dc:creator>RangerofGIS</dc:creator>
      <dc:date>2025-06-18T01:35:20Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Expression for Barcode Scanning Verification</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/arcade-expression-for-barcode-scanning/m-p/1624633#M10967</link>
      <description>&lt;P&gt;There are a few things that need to be fixed in your code.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;The TypeOf&amp;nbsp;documentation seems to be incorrect. It returns "String" instead of "Text" for text. (line 15)&lt;/LI&gt;&lt;LI&gt;Use "Count" instead of "Length" to return the length of a string (lines 20, 21, and 28)&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="javascript"&gt;// barcode variable from feature attribute
var barcodeValue = 'BTR7981006';
Console('Barcode Value: ' + barcodeValue);

// Define valid prefixes for Bin
var validPrefixes = [
'BTR75', 'BTR76', 'BTR780', 'BTR781', 'BTR7820', 'BTR7821', 'BTR7831',
'BTR7846', 'BTR7847', 'BTR7848', 'BTR7855', 'BTR7866', 'BTR789', 'BTR790',
'BTR792', 'BTR798'
];

var isValid = false;

// Check if barcode is empty or not a text value
if (IsEmpty(barcodeValue) || TypeOf(barcodeValue) != 'String') {
  Console('Failed: Empty or non-text');
  isValid = false;
}
// Check if barcode starts with BTR and is 10 characters long
else if (Left(barcodeValue, 3) != 'BTR' || Count(barcodeValue) != 10) {
  Console('Failed: Invalid format, BTR=' + Left(barcodeValue, 3) + ', Length=' + Text(Count(barcodeValue)));
  isValid = false;
}
// Check if barcode starts with any valid prefix
else {
  for (var prefixIndex in validPrefixes) {
    var currentPrefix = validPrefixes[prefixIndex];
    if (Left(barcodeValue, Count(currentPrefix)) == currentPrefix) {
      Console('Passed: Matched prefix ' + currentPrefix);
      isValid = true;
      break;
    }
  }
}

// Return validation result
Console('Result: ' + Text(isValid));
return isValid;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jun 2025 12:30:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/arcade-expression-for-barcode-scanning/m-p/1624633#M10967</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2025-06-18T12:30:47Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Expression for Barcode Scanning Verification</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/arcade-expression-for-barcode-scanning/m-p/1624920#M10979</link>
      <description>&lt;P&gt;Thank you so much! I was pulling my hair out wondering what was wrong.&lt;/P&gt;&lt;P&gt;I understand why you changed the script to string instead of text as text isnt truly an acceptable field type that ESRI uses.&lt;/P&gt;&lt;P&gt;However how did you also know length was not the right function to use?&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jun 2025 04:15:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/arcade-expression-for-barcode-scanning/m-p/1624920#M10979</guid>
      <dc:creator>RangerofGIS</dc:creator>
      <dc:date>2025-06-19T04:15:54Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Expression for Barcode Scanning Verification</title>
      <link>https://community.esri.com/t5/arcgis-field-maps-questions/arcade-expression-for-barcode-scanning/m-p/1626303#M10999</link>
      <description>&lt;P&gt;Length function only accepts featureSet or Geometry arguments.&amp;nbsp; Count can accept string arguments, among others.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="NathanDavis_1-1750788656864.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/134975iAC37A4BB7A784A0E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="NathanDavis_1-1750788656864.png" alt="NathanDavis_1-1750788656864.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="NathanDavis_0-1750788639266.png" style="width: 280px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/134974i0203BF20568BBFCB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="NathanDavis_0-1750788639266.png" alt="NathanDavis_0-1750788639266.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jun 2025 18:11:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-field-maps-questions/arcade-expression-for-barcode-scanning/m-p/1626303#M10999</guid>
      <dc:creator>NathanDavis</dc:creator>
      <dc:date>2025-06-24T18:11:47Z</dc:date>
    </item>
  </channel>
</rss>

