<?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: Change &amp;quot;Assign_Status&amp;quot; by python script for Workforce in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/change-quot-assign-status-quot-by-python-script/m-p/1258456#M66849</link>
    <description>&lt;P&gt;So I was just trying to do something similar, but I wanted any of my assignments that were assigned but not completed to be declined (I run it on a weekly basis for this task) and I set it up as follows:&lt;/P&gt;&lt;PRE&gt;assignments = project.assignments.search(where=&lt;FONT color="#800000"&gt;"status=1"&lt;/FONT&gt;)&lt;BR /&gt;&lt;FONT color="#008000"&gt;for&lt;/FONT&gt; features &lt;FONT color="#008000"&gt;in&lt;/FONT&gt; assignments:&lt;BR /&gt;project.assignments.search(where="status=1")[0].update(&lt;FONT color="#800000"&gt;status="Declined"&lt;/FONT&gt;,declined_date=datetime.datetime.now(), declined_comment=&lt;FONT color="#800000"&gt;"Weekly Timeout of Assignment"&lt;/FONT&gt;)&lt;/PRE&gt;&lt;P&gt;Realizing I have it set up two different ways for status, the value and the alias. And seeing the batch_update command you have in there, may be more efficient ways to do it but hey, it seems to work! I get the schema information from here:&amp;nbsp;&lt;A href="https://doc.arcgis.com/en/workforce/android-phone/help/workforce-schema.htm" target="_blank"&gt;https://doc.arcgis.com/en/workforce/android-phone/help/workforce-schema.htm&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 15 Feb 2023 14:01:29 GMT</pubDate>
    <dc:creator>RobertAnderson3</dc:creator>
    <dc:date>2023-02-15T14:01:29Z</dc:date>
    <item>
      <title>Change "Assign_Status" by python script for Workforce</title>
      <link>https://community.esri.com/t5/python-questions/change-quot-assign-status-quot-by-python-script/m-p/1246770#M66486</link>
      <description>&lt;P&gt;I would like to change the status of all 'assigned' tasks in Workforce to 'Unassigned' , I found the github stript:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;project&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;assignments&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;search&lt;/SPAN&gt;&lt;SPAN class=""&gt;()[&lt;/SPAN&gt;&lt;SPAN class=""&gt;0&lt;/SPAN&gt;&lt;SPAN class=""&gt;]&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;update&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;status&lt;/SPAN&gt;&lt;SPAN class=""&gt;=&lt;/SPAN&gt;&lt;SPAN class=""&gt;"Declined"&lt;/SPAN&gt;&lt;SPAN class=""&gt;,&lt;/SPAN&gt;&lt;SPAN class=""&gt;declined_date&lt;/SPAN&gt;&lt;SPAN class=""&gt;=&lt;/SPAN&gt;&lt;SPAN class=""&gt;datetime&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;datetime&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;now&lt;/SPAN&gt;&lt;SPAN class=""&gt;(),&lt;/SPAN&gt; &lt;SPAN class=""&gt;declined_comment&lt;/SPAN&gt;&lt;SPAN class=""&gt;=&lt;/SPAN&gt;&lt;SPAN class=""&gt;"not doing it"&lt;/SPAN&gt;&lt;SPAN class=""&gt;)&lt;/SPAN&gt;
&lt;SPAN class=""&gt;print&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;"Assignments before Deletion: "&lt;/SPAN&gt; &lt;SPAN class=""&gt;+&lt;/SPAN&gt; &lt;SPAN class=""&gt;str&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;len&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;project&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;assignments&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;search&lt;/SPAN&gt;&lt;SPAN class=""&gt;())))&lt;/SPAN&gt;
&lt;SPAN class=""&gt;project&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;assignments_item&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;layers&lt;/SPAN&gt;&lt;SPAN class=""&gt;[&lt;/SPAN&gt;&lt;SPAN class=""&gt;0&lt;/SPAN&gt;&lt;SPAN class=""&gt;]&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;delete_features&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;where&lt;/SPAN&gt;&lt;SPAN class=""&gt;=&lt;/SPAN&gt;&lt;SPAN class=""&gt;"status=4"&lt;/SPAN&gt;&lt;SPAN class=""&gt;)&lt;/SPAN&gt;
&lt;SPAN class=""&gt;print&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;"Assignments after Deletion: "&lt;/SPAN&gt; &lt;SPAN class=""&gt;+&lt;/SPAN&gt; &lt;SPAN class=""&gt;str&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;len&lt;/SPAN&gt;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;project&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;assignments&lt;/SPAN&gt;&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;search&lt;/SPAN&gt;&lt;SPAN class=""&gt;())))&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;that I have changed to :&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;project.assignments.search()[0].update(status="Assigned")&lt;BR /&gt;print("Assignments before Change: " + str(len(project.assignments.search())))&lt;BR /&gt;project.assignments_item.layers[0].delete_features(where="status=1")&lt;BR /&gt;print("Assignments after Change: " + str(len(project.assignments.search())))&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;but I'm new at Python; I don't want to 'delete.features' but adapt, change this (where="status=1") to ....&amp;nbsp; (where="status=0")&lt;/P&gt;&lt;P&gt;How to to this ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2023 14:30:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-quot-assign-status-quot-by-python-script/m-p/1246770#M66486</guid>
      <dc:creator>FrederikPicavet</dc:creator>
      <dc:date>2023-01-10T14:30:52Z</dc:date>
    </item>
    <item>
      <title>Re: Change "Assign_Status" by python script for Workforce</title>
      <link>https://community.esri.com/t5/python-questions/change-quot-assign-status-quot-by-python-script/m-p/1250414#M66615</link>
      <description>&lt;P&gt;I was hoping to get some answers from this forum ....&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like all tasks in workforce that are assigned or unassigned&amp;nbsp; to be marked as completed :&lt;/P&gt;&lt;LI-CODE lang="c"&gt;# as completed
for assignment in assignments:
        if assignment.status == "unassigned":
            assignment.status = "completed"
        if assignment.status == "assigned":
            assignment.status = "completed"
assignments = project.assignments.batch_update(assignments)&lt;/LI-CODE&gt;&lt;LI-CODE lang="c"&gt;---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
&amp;lt;ipython-input-18-cdac3234566c&amp;gt; in &amp;lt;module&amp;gt;
      1 # as completed
      2 for assignment in assignments:
----&amp;gt; 3         if assignment.status == "unassigned":
      4             assignment.status = "completed"
      5         if assignment.status == "assigned":

AttributeError: 'Feature' object has no attribute 'status'&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How to do this ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you for the help&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jan 2023 15:36:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-quot-assign-status-quot-by-python-script/m-p/1250414#M66615</guid>
      <dc:creator>FrederikPicavet</dc:creator>
      <dc:date>2023-01-23T15:36:32Z</dc:date>
    </item>
    <item>
      <title>Re: Change "Assign_Status" by python script for Workforce</title>
      <link>https://community.esri.com/t5/python-questions/change-quot-assign-status-quot-by-python-script/m-p/1258456#M66849</link>
      <description>&lt;P&gt;So I was just trying to do something similar, but I wanted any of my assignments that were assigned but not completed to be declined (I run it on a weekly basis for this task) and I set it up as follows:&lt;/P&gt;&lt;PRE&gt;assignments = project.assignments.search(where=&lt;FONT color="#800000"&gt;"status=1"&lt;/FONT&gt;)&lt;BR /&gt;&lt;FONT color="#008000"&gt;for&lt;/FONT&gt; features &lt;FONT color="#008000"&gt;in&lt;/FONT&gt; assignments:&lt;BR /&gt;project.assignments.search(where="status=1")[0].update(&lt;FONT color="#800000"&gt;status="Declined"&lt;/FONT&gt;,declined_date=datetime.datetime.now(), declined_comment=&lt;FONT color="#800000"&gt;"Weekly Timeout of Assignment"&lt;/FONT&gt;)&lt;/PRE&gt;&lt;P&gt;Realizing I have it set up two different ways for status, the value and the alias. And seeing the batch_update command you have in there, may be more efficient ways to do it but hey, it seems to work! I get the schema information from here:&amp;nbsp;&lt;A href="https://doc.arcgis.com/en/workforce/android-phone/help/workforce-schema.htm" target="_blank"&gt;https://doc.arcgis.com/en/workforce/android-phone/help/workforce-schema.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 14:01:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/change-quot-assign-status-quot-by-python-script/m-p/1258456#M66849</guid>
      <dc:creator>RobertAnderson3</dc:creator>
      <dc:date>2023-02-15T14:01:29Z</dc:date>
    </item>
  </channel>
</rss>

