This script copies assignments from the workforce project to another feature service
Supports Python 3.5+
This script relies on a JSON configuration file that maps the original field names to the field names in the target feature service (fields may vary, change this config file as needed). An example file for Classic projects is available here and another sample is available here for Offline enabled projects (version 2). The target OBJECTID and GlobalID fields must have different names such as Original_OBJECTID and Original_GlobalID, as these fields are auto-generated when creating a new feature. If you use a mapping like (OBJECTID => OBJECTID, GlobalID => GlobalID) rather than (OBJECTID => Original_OBJECTID, GlobalID => Original_Global_ID), then you may see duplicate items copied over, since the source GlobalID and OBJECTID values will not be stored in the target features. The OBJECTID field in the target feature layer should be an Integer, the GlobalID field in the target feature layer should be String.
The script uses the following parameters:
- -config-file <configFile> The json file containing the field mappings
- -log-file <logFile> The log file to use for logging messages
- -project-id <projectId> - The workforce project ID (from AGOL). For a version 1 project, this is the item ID of the Workforce project item. For a version 2 project, this is the item ID of the Workforce feature service (both found in the web app URL "projects/{project_id}/dispatch")
- -target-fl <targetFL> - The full url of the target feature layer where the assignments will be copied to
- -where <where> - The where clause to use when querying the assignments to copy (Optional - Defaults to '1=1')
- --copy-attachments - A flag that when set will copy the attachments to the target feature layer (this can be slow if there are a lot attachments or features)
Example Usage:
python copy_assignments_to_fs.py -config-file "../sample_data/fieldMappings.json" -u username -p password -org "https://<org>.maps.arcgis.com" -target-fl "http://services.arcgis.com/<server>/arcgis/rest/services/AssignmentsArchives/FeatureServer/0" -where "1=1" -project-id "038a1926d2d741dc8acabefd5b2cc5d3" -log-file "log.txt" --copy-attachments
- First the script uses the provided credentials to authenticate with AGOL to get the requried token
- Then the project is fetched
- Then the JSON configuration file is opened
- The assignments are queried
- The features in the target feature layer are queried
- Assignments not already in the target feature layer are determined
- The assignments are added to the target feature layer
- Attachments are copied to the target feature layer (optional)