<?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 Calculate Field: Python Code Block: GP Tool Not Passing All Parameters to Code Block's Function in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/calculate-field-python-code-block-gp-tool-not/m-p/1070173#M42208</link>
    <description>&lt;P&gt;I tried running Calculate Field with a code block that defined a function:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def test(incdt, t):
    result = None
    if t != "":
        result = incdt.date() + datetime.timedelta(seconds=float(t))
    return result&lt;/LI-CODE&gt;&lt;P&gt;I ran the GP tool with the following expression:&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;test(!Time_Sent_To_Queue!, !F1st_Unit_Assigned!)&lt;/P&gt;&lt;P&gt;But, Pro says that its own GP tool isn't passing both fields. The GP tool returns:&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;TypeError: test() missing 1 required positional argument: 't'&lt;/P&gt;&lt;P&gt;I'm running Pro 2.8.0 on Windows 10.&lt;/P&gt;&lt;P&gt;What would make Pro fail to pass both fields to the function? The 2 source fields are of type Date and Text respectively. The destination field is a Date field.&lt;/P&gt;&lt;P&gt;Full GP tool history entry below:&lt;/P&gt;&lt;P&gt;Calculate Field&lt;BR /&gt;=====================&lt;BR /&gt;Parameters&lt;/P&gt;&lt;P&gt;Input Table AllColumns&lt;BR /&gt;Field Name (Existing or New) F1stUA_DT&lt;BR /&gt;Expression test(!Time_Sent_To_Queue!, !F1st_Unit_Assigned!)&lt;BR /&gt;Expression Type PYTHON3&lt;BR /&gt;Code Block def test(incdt, t):&lt;BR /&gt;result = None&lt;BR /&gt;if t != "":&lt;BR /&gt;result = incdt.date() + datetime.timedelta(seconds=float(t))&lt;BR /&gt;return result&lt;BR /&gt;Updated Input Table AllColumns&lt;BR /&gt;Field Type DATE&lt;BR /&gt;Enforce Domains NO_ENFORCE_DOMAINS&lt;BR /&gt;=====================&lt;BR /&gt;Messages&lt;/P&gt;&lt;P&gt;Start Time: Sunday, June 20, 2021 12:33:34 AM&lt;BR /&gt;ERROR 000539: Traceback (most recent call last):&lt;BR /&gt;File "&amp;lt;expression&amp;gt;", line 1, in &amp;lt;module&amp;gt;&lt;BR /&gt;TypeError: test() missing 1 required positional argument: 't'&lt;/P&gt;&lt;P&gt;Failed to execute (CalculateField).&lt;BR /&gt;Failed at Sunday, June 20, 2021 12:33:34 AM (Elapsed Time: 0.14 seconds)&lt;/P&gt;</description>
    <pubDate>Sun, 20 Jun 2021 07:38:56 GMT</pubDate>
    <dc:creator>ZianChoy</dc:creator>
    <dc:date>2021-06-20T07:38:56Z</dc:date>
    <item>
      <title>Calculate Field: Python Code Block: GP Tool Not Passing All Parameters to Code Block's Function</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/calculate-field-python-code-block-gp-tool-not/m-p/1070173#M42208</link>
      <description>&lt;P&gt;I tried running Calculate Field with a code block that defined a function:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;def test(incdt, t):
    result = None
    if t != "":
        result = incdt.date() + datetime.timedelta(seconds=float(t))
    return result&lt;/LI-CODE&gt;&lt;P&gt;I ran the GP tool with the following expression:&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;test(!Time_Sent_To_Queue!, !F1st_Unit_Assigned!)&lt;/P&gt;&lt;P&gt;But, Pro says that its own GP tool isn't passing both fields. The GP tool returns:&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;TypeError: test() missing 1 required positional argument: 't'&lt;/P&gt;&lt;P&gt;I'm running Pro 2.8.0 on Windows 10.&lt;/P&gt;&lt;P&gt;What would make Pro fail to pass both fields to the function? The 2 source fields are of type Date and Text respectively. The destination field is a Date field.&lt;/P&gt;&lt;P&gt;Full GP tool history entry below:&lt;/P&gt;&lt;P&gt;Calculate Field&lt;BR /&gt;=====================&lt;BR /&gt;Parameters&lt;/P&gt;&lt;P&gt;Input Table AllColumns&lt;BR /&gt;Field Name (Existing or New) F1stUA_DT&lt;BR /&gt;Expression test(!Time_Sent_To_Queue!, !F1st_Unit_Assigned!)&lt;BR /&gt;Expression Type PYTHON3&lt;BR /&gt;Code Block def test(incdt, t):&lt;BR /&gt;result = None&lt;BR /&gt;if t != "":&lt;BR /&gt;result = incdt.date() + datetime.timedelta(seconds=float(t))&lt;BR /&gt;return result&lt;BR /&gt;Updated Input Table AllColumns&lt;BR /&gt;Field Type DATE&lt;BR /&gt;Enforce Domains NO_ENFORCE_DOMAINS&lt;BR /&gt;=====================&lt;BR /&gt;Messages&lt;/P&gt;&lt;P&gt;Start Time: Sunday, June 20, 2021 12:33:34 AM&lt;BR /&gt;ERROR 000539: Traceback (most recent call last):&lt;BR /&gt;File "&amp;lt;expression&amp;gt;", line 1, in &amp;lt;module&amp;gt;&lt;BR /&gt;TypeError: test() missing 1 required positional argument: 't'&lt;/P&gt;&lt;P&gt;Failed to execute (CalculateField).&lt;BR /&gt;Failed at Sunday, June 20, 2021 12:33:34 AM (Elapsed Time: 0.14 seconds)&lt;/P&gt;</description>
      <pubDate>Sun, 20 Jun 2021 07:38:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/calculate-field-python-code-block-gp-tool-not/m-p/1070173#M42208</guid>
      <dc:creator>ZianChoy</dc:creator>
      <dc:date>2021-06-20T07:38:56Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Field: Python Code Block: GP Tool Not Passing All Parameters to Code Block's Function</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/calculate-field-python-code-block-gp-tool-not/m-p/1070176#M42209</link>
      <description>&lt;P&gt;try adding&lt;/P&gt;&lt;P&gt;import datetime&lt;/P&gt;&lt;P&gt;before the def line&lt;/P&gt;&lt;P&gt;also, try switching the order of the parameters in the def to see if it still errors out&lt;/P&gt;</description>
      <pubDate>Sun, 20 Jun 2021 08:51:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/calculate-field-python-code-block-gp-tool-not/m-p/1070176#M42209</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-06-20T08:51:21Z</dc:date>
    </item>
  </channel>
</rss>

