<?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: Assigning field name based on user input in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/assigning-field-name-based-on-user-input/m-p/473076#M15818</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It's pretty easy&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to create&amp;nbsp;a string parameter value filter to set the choices to a limited list of strings. When the model tool is run, it will present a picklist of keywords (which can be the same as the list of field names you want).&lt;/P&gt;&lt;P&gt;&lt;A href="http://desktop.arcgis.com/en/arcmap/latest/analyze/modelbuilder/value-list-filter.htm" style="color: #2989c5; text-decoration: none;" title="http://desktop.arcgis.com/en/arcmap/latest/analyze/modelbuilder/value-list-filter.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Value list filter—Help | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://pro.arcgis.com/en/pro-app/help/analysis/geoprocessing/modelbuilder/model-parameters.htm" style="color: #2989c5; text-decoration: none;" title="http://pro.arcgis.com/en/pro-app/help/analysis/geoprocessing/modelbuilder/model-parameters.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Model parameters—ArcGIS Pro | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want the model to figure out the name without the user having to know, branching your model (as Dan suggests) is an option, but I think it's easier to use Calculate Value to calculate your field name. Either approach will require some scripting.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="comment token"&gt;# Calculate Value Expression&lt;/SPAN&gt;
GetFieldName&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;r&lt;SPAN class="string token"&gt;"%table%"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# Code Block&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;GetFieldName&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;tbl&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp; &lt;SPAN class="comment token"&gt;# use field name to figure out what sort of table, &lt;/SPAN&gt;
&amp;nbsp; &lt;SPAN class="comment token"&gt;# if KEYFIELD is not there, returns empty (false)&lt;/SPAN&gt;
&amp;nbsp; &lt;SPAN class="comment token"&gt;# and field name is assigned "FIELDNAME2"&lt;/SPAN&gt;
&amp;nbsp; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListFields&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;tbl&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"KEYFIELD"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; fname &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"FIELDNAME1"&lt;/SPAN&gt;
&amp;nbsp; &lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; fname &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"FIELDNAME2"&lt;/SPAN&gt;
&amp;nbsp; &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; fname
&lt;SPAN class="comment token"&gt;# Data Type&lt;/SPAN&gt;
String‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 20:54:53 GMT</pubDate>
    <dc:creator>curtvprice</dc:creator>
    <dc:date>2021-12-11T20:54:53Z</dc:date>
    <item>
      <title>Assigning field name based on user input</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/assigning-field-name-based-on-user-input/m-p/473074#M15816</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to create a model where I add multiple new fields to a feature class and to do some other geoprocessing tasks. Is there a way to choose what the field names will be based on user input? I have one field that I add to the feature class which depends on what the data represents and I was wondering if there is a way where I can when running the model select one of two options to what the field should be called.&amp;nbsp; I also wanted to do it so that I could select whether it will add the WAperiod&amp;nbsp;field. I am pretty new to this so I can imagine its something very simple&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jan 2018 14:51:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/assigning-field-name-based-on-user-input/m-p/473074#M15816</guid>
      <dc:creator>TomPiggott</dc:creator>
      <dc:date>2018-01-22T14:51:46Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning field name based on user input</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/assigning-field-name-based-on-user-input/m-p/473075#M15817</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As for providing options as to which field name to choose, you can check the 'branching' section of modelbuilder to see how 'if-else' conditions are implemented. &amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Jan 2018 17:22:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/assigning-field-name-based-on-user-input/m-p/473075#M15817</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2018-01-22T17:22:15Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning field name based on user input</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/assigning-field-name-based-on-user-input/m-p/473076#M15818</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It's pretty easy&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to create&amp;nbsp;a string parameter value filter to set the choices to a limited list of strings. When the model tool is run, it will present a picklist of keywords (which can be the same as the list of field names you want).&lt;/P&gt;&lt;P&gt;&lt;A href="http://desktop.arcgis.com/en/arcmap/latest/analyze/modelbuilder/value-list-filter.htm" style="color: #2989c5; text-decoration: none;" title="http://desktop.arcgis.com/en/arcmap/latest/analyze/modelbuilder/value-list-filter.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Value list filter—Help | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="http://pro.arcgis.com/en/pro-app/help/analysis/geoprocessing/modelbuilder/model-parameters.htm" style="color: #2989c5; text-decoration: none;" title="http://pro.arcgis.com/en/pro-app/help/analysis/geoprocessing/modelbuilder/model-parameters.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Model parameters—ArcGIS Pro | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want the model to figure out the name without the user having to know, branching your model (as Dan suggests) is an option, but I think it's easier to use Calculate Value to calculate your field name. Either approach will require some scripting.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="comment token"&gt;# Calculate Value Expression&lt;/SPAN&gt;
GetFieldName&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;r&lt;SPAN class="string token"&gt;"%table%"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="comment token"&gt;# Code Block&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;GetFieldName&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;tbl&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp; &lt;SPAN class="comment token"&gt;# use field name to figure out what sort of table, &lt;/SPAN&gt;
&amp;nbsp; &lt;SPAN class="comment token"&gt;# if KEYFIELD is not there, returns empty (false)&lt;/SPAN&gt;
&amp;nbsp; &lt;SPAN class="comment token"&gt;# and field name is assigned "FIELDNAME2"&lt;/SPAN&gt;
&amp;nbsp; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListFields&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;tbl&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"KEYFIELD"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; fname &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"FIELDNAME1"&lt;/SPAN&gt;
&amp;nbsp; &lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; fname &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"FIELDNAME2"&lt;/SPAN&gt;
&amp;nbsp; &lt;SPAN class="keyword token"&gt;return&lt;/SPAN&gt; fname
&lt;SPAN class="comment token"&gt;# Data Type&lt;/SPAN&gt;
String‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 20:54:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/assigning-field-name-based-on-user-input/m-p/473076#M15818</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-11T20:54:53Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning field name based on user input</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/assigning-field-name-based-on-user-input/m-p/473077#M15819</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Brilliant! thanks for the help guys&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jan 2018 20:20:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/assigning-field-name-based-on-user-input/m-p/473077#M15819</guid>
      <dc:creator>TomPiggott</dc:creator>
      <dc:date>2018-01-23T20:20:10Z</dc:date>
    </item>
  </channel>
</rss>

