Connect to ArcGIS Workforce

Many times, public comment applications generate feedback that require field investigation before it can be resolved. ArcGIS Workforce can be used to assign field work and track activity conducted to resolve a public report.

The workforce assignment script can be used to create new ArcGIS Workforce assignments from report features that exists in other feature layers on a regularly scheduled interval. This script can be scheduled to run as frequently as you want using Windows Task Scheduler, but only one instance of the task can be running at a single time.

Configuring and executing this script requires the following components:

Once these components are installed, ensure that your Python IDE is set to work against your Python 3 installation that contains the ArcGIS API for Python library (for example, <default directory>\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-python3\python.exe).

Configure reports layers for Workforce attributes

Workforce assignments require certain attribute values to show up in the Dispatcher and Workforce applications. When these attributes are populated from another layer, domain values for these fields must match.

Before the script can copy reports between the reporting and Workforce layers, update the reporting layers to use the same domain values as the Workforce layers.

  1. In ArcGIS Pro, open the Solution Deployment Tool from the Share tab and open the Configure an ArcGIS Solution task.
  2. Ensure you are signed in with an account that can access your Workforce project, then click Next Step and Skip to get to the Modify Domains tool.
  3. Open the assignments layer that was created as part of the Workforce project and choose the Assignment Type field.
  4. Copy, write down, or grab a screenshot of the domain codes and descriptions for this field.
  5. Open the reporting layer and choose the field that contains the values that will be copied to the Assignment Type field. The Assignment Type value is required to create a new assignment and must come from the reporting layer.
  6. Verify that all assignment types that will be copied to the Workforce layer contain the same domain code in both the Workforce and the reports layers. If they don't match, update the report layer domain code to match the Workforce domain code. The domain descriptions can be different.
  7. By default, the status of assignments created by the script will be Unassigned. Alternatively, use a value from the reports layer by completing the following steps:
    1. Still in the Modify Domains tool, open the assignments layer that was created as part of the Workforce project and choose the Status field.
    2. Copy, write down, or grab a screenshot of the domain codes and descriptions for this field.
    3. Open the reporting layer and choose the field that contains the values that will be copied to the Status field.
    4. Verify that all status values that will be copied to the Workforce layer contain the same domain code in both the Workforce and the reports layers. If they don't match, update the report layer domain code to match the Workforce domain code. The domain descriptions can be different.
  8. By default, the priority of assignments created by the script will be None. Alternatively, use a value from the reports layer by completing the following steps:
    1. Still in the Modify Domains tool, open the assignments layer that was created as part of the Workforce project and choose the Priority field.
    2. Copy, write down, or grab a screenshot of the domain codes and descriptions for this field.
    3. Open the reporting layer and choose the field that contains the values that will be copied to the Priority field.
    4. Verify that all priority values that will be copied to the Workforce layer contain the same domain code in both the Workforce and the reports layers. If they don't match, update the report layer domain code to match the Workforce domain code. The domain descriptions can be different.
  9. Optionally, if the worker to be assigned is a value that will come from the report layer, complete the the following steps:
    1. Still in the Modify Domains tool, open the assignments layer that was created as part of the Workforce project and choose the WorkerID field.
    2. Copy, write down, or grab a screenshot of the domain codes and descriptions for this field.
    3. Still in the Modify Domains tool, open the reporting layer and choose the field that contains the values that will be copied to the WorkerID field.
    4. Verify that all worker IDs that will be copied to the Workforce layer contain the same domain code in both the Workforce and the reports layers. If they don't match, update the report layer domain code to match the Workforce domain code. The domain descriptions can be different.

Script configuration

To configure the workforce assignment script to copy features into the Workforce assignments layer, complete the following steps:

  1. Download the Create Workforce Assignments script.
  2. Unzip the downloaded files and use a Python IDE or text editor to open the create_workforce_assignments.py file.
  3. Provide the URL to your ArcGIS Online organization or ArcGIS Enterprise portal and the credentials to a built-in account in that portal or organization that can edit the reports and assignments layers in the orgURL, username, and password parameters
  4. List the service or services to scan in the services parameter. The settings for each service should be enclosed in curly brackets { }. You can add more services by copying and pasting one of these sections surrounded by curly brackets and updating the values for your next service. Be sure to separate each block from the next with a comma. All parameters for all services should be enclosed in a set of square brackets [ ] following the line services = . For each service, provide the following values:
    • 'source url': The URL to the REST endpoint of the feature service containing the reports that will be used to generate the assignments. This URL should end with the layer index number so that it points to a specific layer in the service, for example http://services.arcgis.com/My1Org23GU4I5dAb/arcgis/rest/services/MyServiceName/FeatureServer/0.
    • 'target url': The URL to the REST endpoint of the Workforce assignments layer where the new assignments will be created. This URL should also end with a layer index number that points to a specific layer in the service.
    • 'query': SQL query used to identify the features to copy from the source layer to the target (Workforce) layer. Typically, you will want to define this query so that it excludes features that have already been processed or that don’t need processing.
    • 'fields': Pairs of fields that map how information should be copied from the Reporter layer to the Workforce layer. These fields should be listed as 'Reporter Field': 'Workforce Field', and each field pair must be separated from the previous pair with a comma. At a minimum, this space should map the Workforce field Assignment Type to the reports field containing these values. Values will be automatically generated for OBJECTID and GUID fields so these fields should not be mapped. The Workforce documentation contains a full explanation of fields in the assignments layer.
    • 'update field': Field to update on the source layer to indicate that the record has been copied to Workforce.
    • 'update value': Value in the update field that indicates a record has been copied to Workforce.
    If you have configured the script to use two services, the configuration should look something like this:
      
    services = [{'source url': 'https://services.arcgis.com/My1Org23GU4I5dAb/ArcGIS/rest/services/MyReports1/FeatureServer/0',
                 'target url':'https://services.arcgis.com/My1Org23GU4I5dAb/arcgis/rest/services/assignments_ab123c456de7890fg12345h6789i012j/FeatureServer/0',
                 'query': "STATUS = 'Received'",
                 'fields': {'DETAILS': 'Description',
                            'PROBTYPE': 'AssignmentType',
                            'LOCDESC': 'Location'},
                 'update field': 'STATUS',
                 'update value': 'In Progress'},
               
                {'source url': 'https://services.arcgis.com/My1Org23GU4I5dAb/ArcGIS/rest/services/MyReports2/FeatureServer/0',
                 'target url':'https://services.arcgis.com/My1Org23GU4I5dAb/arcgis/rest/services/assignments_g12345h6789i012jab123c456de7890f/FeatureServer/0',
                 'query': "STATUS = 'Received'",
                 'fields': {'DETAILS': 'Description',
                            'PROBTYPE': 'AssignmentType',
                            'LOCDESC': 'Location'},
                 'update field': 'STATUS',
                 'update value': 'In Progress'}
               ]
          
        

Set up Task Scheduler

Use Windows Task Scheduler to schedule the script to regularly scan the configured services and create assignments from the specified reports.

  1. Open the Task Scheduler on the desktop computer that is hosting the scripts.
  2. Click Action > Create Task and name your task.
  3. Click the Action tab and click New.
  4. Set Action to Start a Program.
  5. Browse to the location of your Python 3 installation (for example, <default directory>\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-python3\python.exe).
  6. In the Add arguments text box, type the name of the script (create_workforce_assignments.py).
  7. In the Start in text box, type the path to the folder where your script is and click OK.
  8. Click the Trigger tab, click New, and set a schedule for your task.
  9. Click OK. When the trigger occurs, the scripts will begin scanning the specified layers.
Top