Select to view content in your preferred language

Cannot create Workforce assignment

536
1
08-26-2022 08:17 AM
Brian_Laws
Occasional Contributor

I am new to Python script writing, but I am trying to learn!

I wish to write a script that will create a Workforce assignment depending on the results from a fire hydrant inspection.  Both the inspection feature service and the Workforce service are hosted on our Enterprise Portal, version 10.9.1.  I tried to follow the section on this page Managing Workforce projects | ArcGIS API for Python that talks about creating a new assignment but I keep coming up with errors that I can't figure out how to fix.  I only really need three attributes to pass over to the assignments creation (geometry, assignment_type, and description) and looking at the page arcgis.apps.workforce.managers module | ArcGIS API for Python section for adding assignments it looked to me that all the attributes are optional, but I kept getting errors that there needs to be a location and the status can't be none so I added them as well.

Here's the code I've been trying:

Python Code.jpg

And here's the output I'm getting:

Python Result 1.jpgPython Result 2.jpg

I've done all the googling I can for now so I'm hoping to get some help here in either how to fix this code, or find a better way to script creating a new assignment.  Any help would be appreciated!

Brian

0 Kudos
1 Reply
Brian_Laws
Occasional Contributor

So after a month of plugging away at this code . . . we've discovered that some of our other scripts that were previously working when we wrote them were now throwing some of the same errors as I was getting with this code.  (This seemed to happen after we upgraded to ArcGIS Pro 3.0)  After some trial and error with the previously working scripts we found that if we just connected with our Enterprise/Portal without specifying a username or password then the script would run as it did before.  I then tried the same thing with this script and it looked like it was going to work, but then after about 7 minutes I get the following errors:

Python Error 1.jpgPython Error 2.jpgPython Error 3.jpg

It looks like it's connecting to the Workforce project, but can't write the new assignment and times out after some period of time. 

Another troubleshooting step we tried was to create a Workforce project in ArcGIS Online and edit the code in the script to connect to ArcGIS Online, then connect to that project,  and then add an assignment to that new project.  It worked as expected.

As I said before, our Enterprise/Portal is at version 10.9.1 and we use Integrated Windows Authority (IWA) to have users log into that.  We have had issues with other Esri applications because we use IWA and I was wondering if that could be our issue here as well?

Again, any help would be appreciated.

0 Kudos