Spatially assigning work to workers using arcgis api for python

72
0
a month ago
SpheleleNtilane7
New Contributor

Hi, my name is Sphelele and I am trying to automate workforce for arcgis . I have constructed a script able to create a project and create assignments but I am stuck on the last part of assigning those assignments to workers. The below part of the script is the part where I am currently suck on. It runs but nothing happens on my workforce project. Thus my workers are not getting assigned to existing assignments

sno = project.workers.get(user_id="snobani.dweku_ethekwini")
sgcino = project.workers.get(user_id="emcorporategis9")
for assignment in assignments:
contains = districts_df["SHAPE"].geom.contains(Geometry(assignment.geometry))
containers = districts_df[contains]
if not containers.empty:
DISTRICTS = containers['DISTRICTS'].iloc[0]
if DISTRICTS == 3:
assignment.worker = sno
assignment.status = "assigned"
assignment.assigned_date = datetime.utcnow()
elif DISTRICTS == 5:
assignment.worker = sgcino
assignment.status = "assigned"
assignment.assigned_date = datetime.utcnow()
elif DISTRICTS == 6:
assignment.worker = sno
assignment.status = "assigned"
assignment.assigned_date = datetime.utcnow()
assignments = project.assignments.batch_update(assignments)

I am using this script as a guide workforce-scripts/3 - Assigning Work.ipynb at master · Esri/workforce-scripts (github.com) 

Your assistance will be greatly appreciated

0 Kudos
0 Replies