<?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: Process runs and gets expected result using calculate field tool, but will not work with ArcGIS Pro scheduler. in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/process-runs-and-gets-expected-result-using/m-p/315374#M24537</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Again the indentation will put people off from helping you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How have you constructed this tool? Is it from a script or ModelBuilder?&lt;/P&gt;&lt;P&gt;Your path to reference the dataset for CalculateField seems to be based upon the MapDocument being open and using the MapDocument = "Current" but I'm not too sure on the syntax being spat out by Pro here if I'm honest (my lack of knowledge more than anything). I would hazard however that you reference the full filepath to your dataset e.g. r"C:\MyGDB\Feature"&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 23 Jun 2020 22:04:00 GMT</pubDate>
    <dc:creator>DavidPike</dc:creator>
    <dc:date>2020-06-23T22:04:00Z</dc:date>
    <item>
      <title>Process runs and gets expected result using calculate field tool, but will not work with ArcGIS Pro scheduler.</title>
      <link>https://community.esri.com/t5/python-questions/process-runs-and-gets-expected-result-using/m-p/315369#M24532</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Windows 10 Enterprise w/ ArcGIS Pro 2.5.1 and Python 3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have managed to schedule a field concatenation process on the same feature layer that is currently working on a schedule and that process works just fine.&amp;nbsp; For some reason, the following process will execute and create the data I want when I use the calculate field tool, but when I try to schedule it, the arc pro scheduler won't run it at all. There is no error apparent or log file created.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am not an experienced python programmer and have a very rudimentary idea of how this works.&amp;nbsp; I put this together using examples.&amp;nbsp; I have "copied" the python command that the tool generates below. Hopefully this can help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want the script to look and see if the field "advisory_lvl" contains text of "CAUTION" or "CLOSURE" and write the field DESC5 with the&amp;nbsp;appropriate image URL.&amp;nbsp; As I said, this process works perfectly when I initiate it manually using the calculate field tool so I don't really know what's wrong with scheduling it.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This &lt;STRONG&gt;does not&lt;/STRONG&gt; work with the Pro scheduler tool:&lt;/P&gt;&lt;P&gt;arcpy.management.CalculateField(r"Harmful Algal Bloom Report 3\surveyPoint", "DESC5", "Reclass(!advisory_lvl!)", "PYTHON3", @"def Reclass(advisory_lvl):&lt;BR /&gt; if (advisory_lvl == ""CAUTION""):&lt;BR /&gt; return '&amp;lt;a href=""url""&amp;gt;&amp;lt;img src=""url"" style=""width: 150px;""&amp;gt;&amp;lt;/a&amp;gt;'&lt;BR /&gt; elif (advisory_lvl == ""CLOSURE""):&lt;BR /&gt; return '&amp;lt;a href=""url""&amp;gt;&amp;lt;img src=""url"" style=""width: 150px;""&amp;gt;&amp;lt;/a&amp;gt;'&lt;BR /&gt;", "TEXT")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This &lt;STRONG&gt;works&lt;/STRONG&gt; with the Pro scheduler tool:&lt;/P&gt;&lt;P&gt;arcpy.management.CalculateField(r"Harmful Algal Bloom Report 3\surveyPoint", "DESC4", "'&amp;lt;b&amp;gt;Agency:&amp;lt;/b&amp;gt;' + ' ' +&amp;nbsp; str(!agency!) + '&amp;lt;br&amp;gt;' + '&amp;lt;b&amp;gt;Sample Date:&amp;lt;/b&amp;gt;' + ' ' + str(!sample_date!) + '&amp;lt;br&amp;gt;' + '&amp;lt;b&amp;gt;Advisory Level:&amp;lt;/b&amp;gt;' + ' ' + str(!advisory_lvl!) + '&amp;lt;br&amp;gt;' + '&amp;lt;b&amp;gt;Advisory Issued:&amp;lt;/b&amp;gt;' + ' ' + str(!advisory_issued!) + '&amp;lt;br&amp;gt;' + '&amp;lt;b&amp;gt;Advisory Lifted:&amp;lt;/b&amp;gt;' + ' ' + str(!advisory_lifted!) + '&amp;lt;br&amp;gt;' + '&amp;lt;b&amp;gt;Cyanobacteria Density:&amp;lt;/b&amp;gt;' + ' ' + str(!cyano_density!) + '&amp;lt;br&amp;gt;' + '&amp;lt;b&amp;gt;Microcystin:&amp;lt;/b&amp;gt;' + ' ' + str(!microcystin!) + '&amp;lt;br&amp;gt;' + '&amp;lt;b&amp;gt;Anatoxin:&amp;lt;/b&amp;gt;' + ' ' + str(!anatoxin!) ", "PYTHON3", '', "TEXT")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please let me know if there is any other information I can provide.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Update:&lt;/P&gt;&lt;P&gt;ArcPro scheduler creates a task within windows task scheduler.&amp;nbsp; The last run result returns (0x1). Looking at the general history panel it runs pythonw.exe with return code&amp;nbsp;2147942401. This is apparently some form of "illegal function".&amp;nbsp; No idea what or why, especially since other scripts run just fine. I did try running the script&amp;nbsp;"run only when user is logged on" and that doesn't seem to affect anything.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 19 Jun 2020 21:23:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/process-runs-and-gets-expected-result-using/m-p/315369#M24532</guid>
      <dc:creator>ErikLeigh</dc:creator>
      <dc:date>2020-06-19T21:23:18Z</dc:date>
    </item>
    <item>
      <title>Re: Process runs and gets expected result using calculate field tool, but will not work with ArcGIS Pro scheduler.</title>
      <link>https://community.esri.com/t5/python-questions/process-runs-and-gets-expected-result-using/m-p/315370#M24533</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've tried most of the ideas I can find online and nothing.&amp;nbsp; Anyone else got anything?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jun 2020 16:45:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/process-runs-and-gets-expected-result-using/m-p/315370#M24533</guid>
      <dc:creator>ErikLeigh</dc:creator>
      <dc:date>2020-06-23T16:45:25Z</dc:date>
    </item>
    <item>
      <title>Re: Process runs and gets expected result using calculate field tool, but will not work with ArcGIS Pro scheduler.</title>
      <link>https://community.esri.com/t5/python-questions/process-runs-and-gets-expected-result-using/m-p/315371#M24534</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok, so new focus on this same topic.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ArcGIS Pro generates it's own python script to run in windows task scheduler.&amp;nbsp; When I try to run that same script in the command line I get the following syntax error.&amp;nbsp; Can anyone tell me what this is about? The up arrow is supposed to be pointing at the @ symbol. At least that's how it is displayed in the cmd window.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;path\task.py&lt;BR /&gt; File "path\task.py", line 17&lt;BR /&gt; ret = arcpy.management.CalculateField(r"Harmful Algal Bloom Report 3\surveyPoint", "DESC5", "Reclass(!advisory_lvl!)", "PYTHON3", @"def Reclass(advisory_lvl):&lt;BR /&gt; ^&lt;BR /&gt;SyntaxError: invalid syntax&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jun 2020 19:16:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/process-runs-and-gets-expected-result-using/m-p/315371#M24534</guid>
      <dc:creator>ErikLeigh</dc:creator>
      <dc:date>2020-06-23T19:16:06Z</dc:date>
    </item>
    <item>
      <title>Re: Process runs and gets expected result using calculate field tool, but will not work with ArcGIS Pro scheduler.</title>
      <link>https://community.esri.com/t5/python-questions/process-runs-and-gets-expected-result-using/m-p/315372#M24535</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I would imagine the syntax error is in your Reclass(), I've looked at your reclass() code above and apart from struggling a bit with the indentation I can't see what the double-double quotes are for and why it's not erroring on those initially.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jun 2020 20:38:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/process-runs-and-gets-expected-result-using/m-p/315372#M24535</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2020-06-23T20:38:06Z</dc:date>
    </item>
    <item>
      <title>Re: Process runs and gets expected result using calculate field tool, but will not work with ArcGIS Pro scheduler.</title>
      <link>https://community.esri.com/t5/python-questions/process-runs-and-gets-expected-result-using/m-p/315373#M24536</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Full python code created by ArcGIS Pro.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# scheduled task: HABS_DESC5&lt;BR /&gt;import datetime, arcpy&lt;BR /&gt;from xml.sax.saxutils import escape&lt;/P&gt;&lt;P&gt;taskname = "HABS_DESC5"&lt;BR /&gt;ret = None&lt;BR /&gt;ticks = int((datetime.datetime.utcnow() - datetime.datetime(1, 1, 1)).total_seconds() * 10**7)&lt;/P&gt;&lt;P&gt;try:&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;arcpy.env.overwriteOutput = True&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;project = arcpy.mp.ArcGISProject(r'path.aprx')&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;active_map = next((it for it in project.listMaps() if it.getDefinition('v2').uRI == 'CIMPATH=map1/map1.xml'), None)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;if active_map:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;with active_map._arc_object:&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ret = arcpy.management.CalculateField(r"Harmful Algal Bloom Report 3\surveyPoint", "DESC5", "Reclass(!advisory_lvl!)", "PYTHON3", @"def Reclass(advisory_lvl):&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (advisory_lvl == ""CAUTION""):&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return '&amp;lt;a href=""path"" style=""width: 150px;""&amp;gt;&amp;lt;/a&amp;gt;'&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;elif (advisory_lvl == ""CLOSURE""):&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return '&amp;lt;a href=""path"" style=""width: 150px;""&amp;gt;&amp;lt;/a&amp;gt;'&lt;BR /&gt;", "TEXT")&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;else:&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ret = arcpy.management.CalculateField(r"Harmful Algal Bloom Report 3\surveyPoint", "DESC5", "Reclass(!advisory_lvl!)", "PYTHON3", @"def Reclass(advisory_lvl):&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (advisory_lvl == ""CAUTION""):&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return '&amp;lt;a href=""path"" style=""width: 150px;""&amp;gt;&amp;lt;/a&amp;gt;'&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;elif (advisory_lvl == ""CLOSURE""):&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return '&amp;lt;a href=""path"" style=""width: 150px;""&amp;gt;&amp;lt;/a&amp;gt;'&lt;BR /&gt;", "TEXT")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;except:&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;pass&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;finally:&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;ticks2 = int((datetime.datetime.utcnow() - datetime.datetime(1, 1, 1)).total_seconds() * 10**7)&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;status = 0 if ret is None else ret.status if type (ret) == arcpy.Result else 4&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;xml = f'&amp;lt;log status="{status}" start="{ticks}" end="{ticks2}" taskname="{escape(taskname)}"&amp;gt;'&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;xml += '&amp;lt;messages&amp;gt;'&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;try: xml += ''.join([f'&amp;lt;msg code="{msg[0]}" type="{msg[1]}"&amp;gt;{escape(msg[2])}&amp;lt;/msg&amp;gt;' for msg in arcpy.gp.GetAllMessages()])&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;except: pass&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;xml += '&amp;lt;/messages&amp;gt;&amp;lt;/log&amp;gt;'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;log_file = r"path.log".format('%x' % ticks)&lt;BR /&gt; with open(log_file, 'w', encoding='utf-8') as file:&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;file.write(xml)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jun 2020 21:53:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/process-runs-and-gets-expected-result-using/m-p/315373#M24536</guid>
      <dc:creator>ErikLeigh</dc:creator>
      <dc:date>2020-06-23T21:53:21Z</dc:date>
    </item>
    <item>
      <title>Re: Process runs and gets expected result using calculate field tool, but will not work with ArcGIS Pro scheduler.</title>
      <link>https://community.esri.com/t5/python-questions/process-runs-and-gets-expected-result-using/m-p/315374#M24537</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Again the indentation will put people off from helping you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How have you constructed this tool? Is it from a script or ModelBuilder?&lt;/P&gt;&lt;P&gt;Your path to reference the dataset for CalculateField seems to be based upon the MapDocument being open and using the MapDocument = "Current" but I'm not too sure on the syntax being spat out by Pro here if I'm honest (my lack of knowledge more than anything). I would hazard however that you reference the full filepath to your dataset e.g. r"C:\MyGDB\Feature"&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jun 2020 22:04:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/process-runs-and-gets-expected-result-using/m-p/315374#M24537</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2020-06-23T22:04:00Z</dc:date>
    </item>
    <item>
      <title>Re: Process runs and gets expected result using calculate field tool, but will not work with ArcGIS Pro scheduler.</title>
      <link>https://community.esri.com/t5/python-questions/process-runs-and-gets-expected-result-using/m-p/315375#M24538</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry, It pastes without indentation so I went back in and edited it.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes, the path was a full file path. I used the calculate field tool in ArcGIS Pro. Original input to the calculate field tool looks like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Expression:&lt;/P&gt;&lt;P&gt;DESC5=Reclass(!advisory_lvl!)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Code Block:&lt;/P&gt;&lt;P&gt;def Reclass(advisory_lvl):&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (advisory_lvl == "Caution"):&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return '&amp;lt;a href="path"&amp;gt;&amp;lt;img src="path" style="width: 150px;"&amp;gt;&amp;lt;/a&amp;gt;'&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;elif (advisory_lvl == "Closure"):&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return '&amp;lt;a href="path"&amp;gt;&amp;lt;img src="path" style="width: 150px;"&amp;gt;&amp;lt;/a&amp;gt;'&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jun 2020 22:10:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/process-runs-and-gets-expected-result-using/m-p/315375#M24538</guid>
      <dc:creator>ErikLeigh</dc:creator>
      <dc:date>2020-06-23T22:10:04Z</dc:date>
    </item>
  </channel>
</rss>

