<?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: eSearch substring fields in Web AppBuilder Custom Widgets Questions</title>
    <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/esearch-substring-fields/m-p/766042#M1212</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My link is looking at a {incdate} parameter within the url to open a report for different years. The {incdate} field is displayed like 20160203, I need the first 4 characters to get the correct year but get and error because it's gathering the whole string in the {incdate} field. Will this code allow me to do that?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/180107_pastedImage_0.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/180108_pastedImage_1.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 09 Feb 2016 21:40:01 GMT</pubDate>
    <dc:creator>RudoDuncan</dc:creator>
    <dc:date>2016-02-09T21:40:01Z</dc:date>
    <item>
      <title>eSearch substring fields</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/esearch-substring-fields/m-p/766040#M1210</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/3101"&gt;Robert Scheitlin, GISP&lt;/A&gt;​&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/83912"&gt;Kevin MacLeod&lt;/A&gt;​&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I found this response to one of the questions about substrings and replacing/truncating a specific number of strings. My question is, where do you put the code? Does it go with the config.json file? Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Substring fix.JPG" class="image-1 jive-image" src="/legacyfs/online/179963_Substring fix.JPG" style="width: 620px; height: 661px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Feb 2016 18:47:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/esearch-substring-fields/m-p/766040#M1210</guid>
      <dc:creator>RudoDuncan</dc:creator>
      <dc:date>2016-02-09T18:47:50Z</dc:date>
    </item>
    <item>
      <title>Re: eSearch substring fields</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/esearch-substring-fields/m-p/766041#M1211</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Rudo,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Just in the Widget.js&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You would need to look for more of our conversion (Kevin and I) on this topic:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.esri.com/docs/DOC-1731#comment-20094" title="https://community.esri.com/docs/DOC-1731#comment-20094"&gt;https://community.esri.com/docs/DOC-1731#comment-20094&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.esri.com/docs/DOC-1731#comment-20171" title="https://community.esri.com/docs/DOC-1731#comment-20171"&gt;https://community.esri.com/docs/DOC-1731#comment-20171&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.esri.com/docs/DOC-1731#comment-20172" title="https://community.esri.com/docs/DOC-1731#comment-20172"&gt;https://community.esri.com/docs/DOC-1731#comment-20172&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.esri.com/docs/DOC-1731#comment-20031" title="https://community.esri.com/docs/DOC-1731#comment-20031"&gt;https://community.esri.com/docs/DOC-1731#comment-20031&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.esri.com/docs/DOC-1731#comment-20232" title="https://community.esri.com/docs/DOC-1731#comment-20232"&gt;https://community.esri.com/docs/DOC-1731#comment-20232&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Feb 2016 19:03:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/esearch-substring-fields/m-p/766041#M1211</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2016-02-09T19:03:44Z</dc:date>
    </item>
    <item>
      <title>Re: eSearch substring fields</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/esearch-substring-fields/m-p/766042#M1212</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My link is looking at a {incdate} parameter within the url to open a report for different years. The {incdate} field is displayed like 20160203, I need the first 4 characters to get the correct year but get and error because it's gathering the whole string in the {incdate} field. Will this code allow me to do that?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/180107_pastedImage_0.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/180108_pastedImage_1.png" style="max-width: 1200px; max-height: 900px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Feb 2016 21:40:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/esearch-substring-fields/m-p/766042#M1212</guid>
      <dc:creator>RudoDuncan</dc:creator>
      <dc:date>2016-02-09T21:40:01Z</dc:date>
    </item>
    <item>
      <title>Re: eSearch substring fields</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/esearch-substring-fields/m-p/766043#M1213</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Rudo,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Here is the updated function that should do what you are wanting. I am assuming that the field is a string based on the field content examples you have given. So in the Widget.js replace the existing _substitute function with this one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;_substitute: function (string, Attribs, currentLayer) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var lfields = this._getFieldsfromLink(string);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (var lf = 0; lf &amp;lt; lfields.length; lf++) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (Attribs[lfields[lf]]) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var fld = this._getField(currentLayer, lfields[lf]);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (fld.type === "esriFieldTypeString") {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(lang.trim(lfields[lf]) === 'IncDate'){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var sYear = lang.trim(Attribs[lfields[lf]]).substring(0, 4);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string = string.replace(new RegExp('{' + lang.trim(lfields[lf]) + '}', 'g'), sYear);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }else{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string = string.replace(new RegExp('{' + lang.trim(lfields[lf]) + '}', 'g'), lang.trim(Attribs[lfields[lf]]));
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } else {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string = string.replace(new RegExp('{' + lang.trim(lfields[lf]) + '}', 'g'), Attribs[lfields[lf]]);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return string;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; },&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 08:31:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/esearch-substring-fields/m-p/766043#M1213</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2021-12-12T08:31:06Z</dc:date>
    </item>
  </channel>
</rss>

