<?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 Using the Field Calculator (python) to create Full Path Name for hyperlink in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/using-the-field-calculator-python-to-create-full/m-p/626631#M20818</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm trying to use the field calculator to populate the field "Hyperlink1" with the full path name of the document.&amp;nbsp; I have a field called "DOC_NO" and if there is a document number in it, I would like the field "Hyperlink1" to fill in the path name with the document number.&amp;nbsp; If there is no text in "DOC_NO" I do not want any text in the "Hyperlink1" field.&amp;nbsp; But I can't seem to get it work right.&amp;nbsp; Can anyone take a look?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Pre-Logic Script Code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;def myfunction(docno) :&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; if len(!DOC_NO!) == 0 :&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return ''"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; else:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return "V:\Eng\Land Management\Easements\Scanned Documents\" + !DOC_NO! + ".tif"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hyperlink1=&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;myfunction( !DOC_NO! )&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 25 May 2012 18:14:15 GMT</pubDate>
    <dc:creator>JamieNeils</dc:creator>
    <dc:date>2012-05-25T18:14:15Z</dc:date>
    <item>
      <title>Using the Field Calculator (python) to create Full Path Name for hyperlink</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/using-the-field-calculator-python-to-create-full/m-p/626631#M20818</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm trying to use the field calculator to populate the field "Hyperlink1" with the full path name of the document.&amp;nbsp; I have a field called "DOC_NO" and if there is a document number in it, I would like the field "Hyperlink1" to fill in the path name with the document number.&amp;nbsp; If there is no text in "DOC_NO" I do not want any text in the "Hyperlink1" field.&amp;nbsp; But I can't seem to get it work right.&amp;nbsp; Can anyone take a look?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Pre-Logic Script Code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;def myfunction(docno) :&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; if len(!DOC_NO!) == 0 :&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return ''"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; else:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return "V:\Eng\Land Management\Easements\Scanned Documents\" + !DOC_NO! + ".tif"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hyperlink1=&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;myfunction( !DOC_NO! )&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 May 2012 18:14:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/using-the-field-calculator-python-to-create-full/m-p/626631#M20818</guid>
      <dc:creator>JamieNeils</dc:creator>
      <dc:date>2012-05-25T18:14:15Z</dc:date>
    </item>
    <item>
      <title>Re: Using the Field Calculator (python) to create Full Path Name for hyperlink</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/using-the-field-calculator-python-to-create-full/m-p/626632#M20819</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Outside of your function, you're in ArcGIS world - so you correctly use "!DOC_NO!" to reference the field, which passes each value, then "docno", to the function one at a time. Inside the function, you're in Python world, so you use the variable "docno".&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def myfunction(docno) :
&amp;nbsp;&amp;nbsp; if len(docno)== 0 :
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return ""
&amp;nbsp;&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return "V:\Eng\Land Management\Easements\Scanned Documents\" + docno + ".tif"
 &lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;edit: also, check your quotes after the first return - you've got two single quotes, then a double quote.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:42:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/using-the-field-calculator-python-to-create-full/m-p/626632#M20819</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2021-12-12T02:42:25Z</dc:date>
    </item>
    <item>
      <title>Re: Using the Field Calculator (python) to create Full Path Name for hyperlink</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/using-the-field-calculator-python-to-create-full/m-p/626633#M20820</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If you are going to use backslashes in a string, you need to identify it as a raw string:&lt;/SPAN&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
return r"V:\Eng\Land Management\Easements\Scanned Documents\" + docno + ".tif"&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;so Python doesn't try to interpret the next character as a control character.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:42:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/using-the-field-calculator-python-to-create-full/m-p/626633#M20820</guid>
      <dc:creator>BruceNielsen</dc:creator>
      <dc:date>2021-12-12T02:42:28Z</dc:date>
    </item>
    <item>
      <title>Re: Using the Field Calculator (python) to create Full Path Name for hyperlink</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/using-the-field-calculator-python-to-create-full/m-p/626634#M20821</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Darren is correct; you can't use the "!field!" syntax inside the function. And Bruce too...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's my solution. This would work with either numeric or text fields.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I like to use only one "return" (for readability).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Pre-Logic Script Code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def myfunction(docno):
&amp;nbsp; docno = str(docno).strip() # remove any trailing spaces
&amp;nbsp; if len(docno).strip() == 0:
&amp;nbsp;&amp;nbsp;&amp;nbsp; val = ""
&amp;nbsp; else:
&amp;nbsp;&amp;nbsp;&amp;nbsp; # the "r" is needed
&amp;nbsp;&amp;nbsp;&amp;nbsp; val = r"V:\Eng\Land Management\Easements\Scanned Documents\" + docno + ".tif"
&amp;nbsp; return val
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hyperlink1 =&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;myfunction( !DOC_NO! )&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:42:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/using-the-field-calculator-python-to-create-full/m-p/626634#M20821</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-12T02:42:30Z</dc:date>
    </item>
  </channel>
</rss>

