Workforce 'create assignments from csv' script - no assignments symbolized on map

643
7
05-09-2018 11:54 AM
JayHodny
Occasional Contributor III

Hi all.  I have been learning and using Workforce and the various Python 'create' scripts available from GitHub.  With some excellent help from Esri staff, I had great success using a create assignment script for the Citizen Problem Reporter and Manager solutions.  I am now using 'create assignments from csv' script to automate assignment creation for hydrant flushing.  After a fair amount of trial and error, I was able to have the script create assignments (but without having the Dispatcher or Worker fields populated).  However, the maps in Workforce and Pro, do not show the assignment symbology (unassigned, assigned, in progress, etc.).  The attribute table for the assignment feature service shows the assignment records but again there are no symbols on the maps.  If I use the 'Zoom to' function for a row in the att table, we go nowhere.  I did have trouble executing the script where I had a 'string to float' error on the xField.  After checking each coordinate carefully, and still receiving the same error, I did a copy/paste of the existing csv into a new xlsx/csv file, and the error went away. The script started working and created assignments.

So I need some assistance in getting the assignment features to symbolize please.  The Shape field is populated with Point.

Also, I am stumbling on passing the Dispatchers and Workers from the csv file.  From the schema, the userid fields are text.  In looking at the att tables for both services, the userid columns are populated with our email usernames (e.g., "jhodny@newark.yadda.yadda_CityOfyadda") When I include these two columns in the csv file, I get a 'ValueError: invalid literal for int() with base 10: 'jhodny@newark.yadda.yadda_CityOfyadda' error.  I am not sure what to do here.

Thanks,

Jay

0 Kudos
7 Replies
AaronPulver
Esri Regular Contributor

Hi Jay,

From the schema, the userid fields are text.  In looking at the att tables for both services, the userid columns are populated with our email usernames (e.g., "jhodny@newark.yadda.yadda_CityOfyadda") When I include these two columns in the csv file, I get a 'ValueError: invalid literal for int() with base 10: 'jhodny@newark.yadda.yadda_CityOfyadda' error.  I am not sure what to do here.

We recently updated the workforce-scripts repo to use the new Workforce Module in the Python API for ArcGIS. In the update, we expect the dispatcher and worker attributes to be the named user account (user_id). This should make it easier since you know longer will have to look up the OBJECTID of the workers or dispatchers. This should address the situation you described.

 I did have trouble executing the script where I had a 'string to float' error on the xField.  

It's likely that your CSV file had quotes around the x/y fields which caused it be read as a string instead of as a floating point number.

I am not sure how to address the symbology issue.

Best,

Aaron

0 Kudos
JayHodny
Occasional Contributor III

Hi Aaron,

Thank you for your quick reply. In Pro I have ArcGIS API for Python version 1.2.5 installed.

  • I checked the x,y fields, no quotes, so I assume the copy/paste to a new worksheet cleaned out whatever was causing the initial string error.

  • The ‘create assignment from csv.py’ script I was using had a Feb 2018 date. I downloaded the latest script and ran that. Now I am getting this error:

Traceback (most recent call last):

File "V:\GIS\SolutionTesting\Workforce\HydrantFlushing\create_assignments_from_csv.py", line 35, in

from arcgis.apps import workforce

ModuleNotFoundError: No module named 'arcgis.apps'

I don’t have enough experience yet to figure out what I need to do now to correct this. Please help.

Thanks,

Jay

0 Kudos
AaronPulver
Esri Regular Contributor

You need to upgrade your API to level 1.4.1 to take advantage of the new module.

Instructions can be found here: Install and set up | ArcGIS for Developers 

0 Kudos
JayHodny
Occasional Contributor III

Aaron, I had a hunch this was the case. I was able to upgrade the API. I noticed the command line syntax had changed, so I made those changes too. I also noted I had the wrong wkid value so that is now correct in the command syntax. Running the script returns this now. I am not sure what this error means. Thanks for your help and your patience. Jay

0 Kudos
AaronPulver
Esri Regular Contributor

That is likely caused because in the CSV file you now use the name of the assignment type, rather than the code. So instead of 1 in the CSV you will have "Inspection" or whatever your assignment type is.

0 Kudos
JayHodny
Occasional Contributor III

Aaron,

I like that! I replaced the domain codes (integer values) with the domain descriptions, Flush Hydrant, Fire Flow Test, etc., for the assignment types. That helped but the script is still throwing errors. Can I email you my sample csv file and command line syntax? I think this might be more efficient and easier to troubleshoot.

Thanks,

Jay

jhodny@newark.de.us

0 Kudos
JayHodny
Occasional Contributor III

The assignment locations are now plotting correctly.  I was using the wrong wkid value (found in the original feature class Properties....Source....Projected Coordinate System....WKID).  I was also informed that the latest version of the Python script uses 'assignment type' descriptions instead of integer values, same for the priority field.  Also, worker and dispatcher userids need to match those in AGOL, they are case-sensitive.

0 Kudos