<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Why is the Create workforce assignments not working anymore and how do we work backwards?? in ArcGIS Solutions Questions</title>
    <link>https://community.esri.com/t5/arcgis-solutions-questions/why-is-the-create-workforce-assignments-not/m-p/1015778#M859</link>
    <description>&lt;P&gt;Hey,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;I created a Citizen Problem Reporter using ArcGIS Solutions and I created the Workforce with the directions. I was trying to use the Crowdsource copy over points to the Workforce. Unfortunately,&amp;nbsp; it won't copy over the data. I've tried creating a new Workforce. I even tried creating the Citizen Problem Report from scratch.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I had it working about 2 weeks ago. Then we scrapped the workforce and started a new one because of some glitch we were getting with the Assign feature being unable to click to assign to a person.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The other question I have is there a way to update the Citizen problem reporter app after the worker updates the information in Workforce. My thought is to use the enrich reporter but I first need to get this down so I can get the assignments on the Workforce. Trying to make it as automated as possible since this is only a single department using it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;(&lt;A href="https://solutions.arcgis.com/local-government/help/crowdsource-reporter/get-started/create-workforce-assignments/" target="_blank"&gt;https://solutions.arcgis.com/local-government/help/crowdsource-reporter/get-started/create-workforce-assignments/&lt;/A&gt;)&lt;/P&gt;&lt;P&gt;So now here we are. Below is copy of the script.&amp;nbsp;&lt;/P&gt;&lt;P&gt;# ------------------------------------------------------------------------------&lt;BR /&gt;# Name: create_workforce_assignments.py&lt;BR /&gt;# Purpose: generates identifiers for features&lt;/P&gt;&lt;P&gt;# Copyright 2017 Esri&lt;/P&gt;&lt;P&gt;# Licensed under the Apache License, Version 2.0 (the "License");&lt;BR /&gt;# you may not use this file except in compliance with the License.&lt;BR /&gt;# You may obtain a copy of the License at&lt;BR /&gt;#&lt;BR /&gt;# &lt;A href="http://www.apache.org/licenses/LICENSE-2.0" target="_blank"&gt;http://www.apache.org/licenses/LICENSE-2.0&lt;/A&gt;&lt;BR /&gt;#&lt;BR /&gt;# Unless required by applicable law or agreed to in writing, software&lt;BR /&gt;# distributed under the License is distributed on an "AS IS" BASIS,&lt;BR /&gt;# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.&lt;BR /&gt;# See the License for the specific language governing permissions and&lt;BR /&gt;# limitations under the License.&lt;/P&gt;&lt;P&gt;# ------------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;from datetime import datetime as dt&lt;BR /&gt;from os import path, sys&lt;BR /&gt;from arcgis.gis import GIS&lt;BR /&gt;from arcgis.features import FeatureLayer&lt;BR /&gt;from arcgis.apps import workforce&lt;/P&gt;&lt;P&gt;orgURL = '' # URL to ArcGIS Online organization or ArcGIS Portal&lt;BR /&gt;username = '' # Username of an account in the org/portal that can access and edit all services listed below&lt;BR /&gt;password = '' # Password corresponding to the username provided above&lt;/P&gt;&lt;P&gt;# Specify the services/ layers to monitor for reports to pass to Workforce&lt;BR /&gt;# [{'source url': 'Reporter layer to monitor for new reports',&lt;BR /&gt;# 'target url': 'Workforce layer where new assignments will be created base on the new reports',&lt;BR /&gt;# 'query': 'SQL query used to identify the new reports that should be copied',&lt;BR /&gt;# 'fields': {&lt;BR /&gt;# 'Name of Reporter field': 'Name of Workforce field',&lt;BR /&gt;# 'Another Reporter field to map':'to another workforce field'},&lt;BR /&gt;# 'update field': 'Name of field in Reporter layer tracking which reports have been copied to Workforce',&lt;BR /&gt;# 'update value': 'Value in update field indicating that a report has already been copied.'&lt;BR /&gt;# },&lt;BR /&gt;# {'source url': 'Another Reporter layer to monitor for new reports',&lt;BR /&gt;# 'target url': '',&lt;BR /&gt;# 'query': '',&lt;BR /&gt;# 'fields': {},&lt;BR /&gt;# 'update field': '',&lt;BR /&gt;# 'update value': ''&lt;BR /&gt;# }]&lt;/P&gt;&lt;P&gt;services = [{'source url': '',&lt;BR /&gt;'project': '',&lt;BR /&gt;'query': '1=1',&lt;BR /&gt;'fields': {&lt;BR /&gt;'': ''},&lt;BR /&gt;'update field': '',&lt;BR /&gt;'update value': ''&lt;BR /&gt;}]&lt;/P&gt;&lt;P&gt;def main():&lt;BR /&gt;# Create log file&lt;BR /&gt;with open(path.join(sys.path[0], 'attr_log.log'), 'a') as log:&lt;BR /&gt;log.write('\n{}\n'.format(dt.now()))&lt;/P&gt;&lt;P&gt;# connect to org/portal&lt;BR /&gt;if username:&lt;BR /&gt;gis = GIS(orgURL, username, password)&lt;BR /&gt;else:&lt;BR /&gt;gis = GIS(orgURL)&lt;/P&gt;&lt;P&gt;for service in services:&lt;BR /&gt;try:&lt;BR /&gt;# Connect to source and target layers&lt;BR /&gt;fl_source = FeatureLayer(service['source url'], gis)&lt;BR /&gt;fl_target = FeatureLayer(service['target url'], gis)&lt;/P&gt;&lt;P&gt;# get field map&lt;BR /&gt;fields = [[key, service['fields'][key]] for key in service['fields'].keys()]&lt;/P&gt;&lt;P&gt;# Get source rows to copy&lt;BR /&gt;rows = fl_source.query(service['query'])&lt;BR /&gt;adds = []&lt;BR /&gt;updates = []&lt;/P&gt;&lt;P&gt;for row in rows:&lt;BR /&gt;# Build dictionary of attributes &amp;amp; geometry in schema of target layer&lt;BR /&gt;# Default status and priority values can be overwritten if those fields are mapped to reporter layer&lt;BR /&gt;attributes = {'status': 0,&lt;BR /&gt;'priority': 0}&lt;/P&gt;&lt;P&gt;for field in fields:&lt;BR /&gt;attributes[field[1]] = row.attributes[field[0]]&lt;/P&gt;&lt;P&gt;new_request = {'attributes': attributes,&lt;BR /&gt;'geometry': {'x': row.geometry['x'],&lt;BR /&gt;'y': row.geometry['y']}}&lt;BR /&gt;adds.append(new_request)&lt;/P&gt;&lt;P&gt;# update row to indicate record has been copied&lt;BR /&gt;if service['update field']:&lt;BR /&gt;row.attributes[service['update field']] = service['update value']&lt;BR /&gt;updates.append(row)&lt;/P&gt;&lt;P&gt;# add records to target layer&lt;BR /&gt;if adds:&lt;BR /&gt;add_result = fl_target.edit_features(adds=adds)&lt;BR /&gt;for result in add_result['updateResults']:&lt;BR /&gt;if not result['success']:&lt;BR /&gt;raise Exception('error {}: {}'.format(result['error']['code'],&lt;BR /&gt;result['error']['description']))&lt;/P&gt;&lt;P&gt;# update records:&lt;BR /&gt;if updates:&lt;BR /&gt;update_result = fl_source.edit_features(updates=updates)&lt;BR /&gt;for result in update_result['updateResults']:&lt;BR /&gt;if not result['success']:&lt;BR /&gt;raise Exception('error {}: {}'.format(result['error']['code'],&lt;BR /&gt;result['error']['description']))&lt;/P&gt;&lt;P&gt;except Exception as ex:&lt;BR /&gt;msg = 'Failed to copy feature from layer {}'.format(service['url'])&lt;BR /&gt;print(ex)&lt;BR /&gt;print(msg)&lt;BR /&gt;log.write('{}\n{}\n'.format(msg, ex))&lt;/P&gt;&lt;P&gt;if __name__ == '__main__':&lt;BR /&gt;main()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 11 Jan 2021 22:30:05 GMT</pubDate>
    <dc:creator>Mark_Medina</dc:creator>
    <dc:date>2021-01-11T22:30:05Z</dc:date>
    <item>
      <title>Why is the Create workforce assignments not working anymore and how do we work backwards??</title>
      <link>https://community.esri.com/t5/arcgis-solutions-questions/why-is-the-create-workforce-assignments-not/m-p/1015778#M859</link>
      <description>&lt;P&gt;Hey,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;I created a Citizen Problem Reporter using ArcGIS Solutions and I created the Workforce with the directions. I was trying to use the Crowdsource copy over points to the Workforce. Unfortunately,&amp;nbsp; it won't copy over the data. I've tried creating a new Workforce. I even tried creating the Citizen Problem Report from scratch.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I had it working about 2 weeks ago. Then we scrapped the workforce and started a new one because of some glitch we were getting with the Assign feature being unable to click to assign to a person.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The other question I have is there a way to update the Citizen problem reporter app after the worker updates the information in Workforce. My thought is to use the enrich reporter but I first need to get this down so I can get the assignments on the Workforce. Trying to make it as automated as possible since this is only a single department using it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;(&lt;A href="https://solutions.arcgis.com/local-government/help/crowdsource-reporter/get-started/create-workforce-assignments/" target="_blank"&gt;https://solutions.arcgis.com/local-government/help/crowdsource-reporter/get-started/create-workforce-assignments/&lt;/A&gt;)&lt;/P&gt;&lt;P&gt;So now here we are. Below is copy of the script.&amp;nbsp;&lt;/P&gt;&lt;P&gt;# ------------------------------------------------------------------------------&lt;BR /&gt;# Name: create_workforce_assignments.py&lt;BR /&gt;# Purpose: generates identifiers for features&lt;/P&gt;&lt;P&gt;# Copyright 2017 Esri&lt;/P&gt;&lt;P&gt;# Licensed under the Apache License, Version 2.0 (the "License");&lt;BR /&gt;# you may not use this file except in compliance with the License.&lt;BR /&gt;# You may obtain a copy of the License at&lt;BR /&gt;#&lt;BR /&gt;# &lt;A href="http://www.apache.org/licenses/LICENSE-2.0" target="_blank"&gt;http://www.apache.org/licenses/LICENSE-2.0&lt;/A&gt;&lt;BR /&gt;#&lt;BR /&gt;# Unless required by applicable law or agreed to in writing, software&lt;BR /&gt;# distributed under the License is distributed on an "AS IS" BASIS,&lt;BR /&gt;# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.&lt;BR /&gt;# See the License for the specific language governing permissions and&lt;BR /&gt;# limitations under the License.&lt;/P&gt;&lt;P&gt;# ------------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;from datetime import datetime as dt&lt;BR /&gt;from os import path, sys&lt;BR /&gt;from arcgis.gis import GIS&lt;BR /&gt;from arcgis.features import FeatureLayer&lt;BR /&gt;from arcgis.apps import workforce&lt;/P&gt;&lt;P&gt;orgURL = '' # URL to ArcGIS Online organization or ArcGIS Portal&lt;BR /&gt;username = '' # Username of an account in the org/portal that can access and edit all services listed below&lt;BR /&gt;password = '' # Password corresponding to the username provided above&lt;/P&gt;&lt;P&gt;# Specify the services/ layers to monitor for reports to pass to Workforce&lt;BR /&gt;# [{'source url': 'Reporter layer to monitor for new reports',&lt;BR /&gt;# 'target url': 'Workforce layer where new assignments will be created base on the new reports',&lt;BR /&gt;# 'query': 'SQL query used to identify the new reports that should be copied',&lt;BR /&gt;# 'fields': {&lt;BR /&gt;# 'Name of Reporter field': 'Name of Workforce field',&lt;BR /&gt;# 'Another Reporter field to map':'to another workforce field'},&lt;BR /&gt;# 'update field': 'Name of field in Reporter layer tracking which reports have been copied to Workforce',&lt;BR /&gt;# 'update value': 'Value in update field indicating that a report has already been copied.'&lt;BR /&gt;# },&lt;BR /&gt;# {'source url': 'Another Reporter layer to monitor for new reports',&lt;BR /&gt;# 'target url': '',&lt;BR /&gt;# 'query': '',&lt;BR /&gt;# 'fields': {},&lt;BR /&gt;# 'update field': '',&lt;BR /&gt;# 'update value': ''&lt;BR /&gt;# }]&lt;/P&gt;&lt;P&gt;services = [{'source url': '',&lt;BR /&gt;'project': '',&lt;BR /&gt;'query': '1=1',&lt;BR /&gt;'fields': {&lt;BR /&gt;'': ''},&lt;BR /&gt;'update field': '',&lt;BR /&gt;'update value': ''&lt;BR /&gt;}]&lt;/P&gt;&lt;P&gt;def main():&lt;BR /&gt;# Create log file&lt;BR /&gt;with open(path.join(sys.path[0], 'attr_log.log'), 'a') as log:&lt;BR /&gt;log.write('\n{}\n'.format(dt.now()))&lt;/P&gt;&lt;P&gt;# connect to org/portal&lt;BR /&gt;if username:&lt;BR /&gt;gis = GIS(orgURL, username, password)&lt;BR /&gt;else:&lt;BR /&gt;gis = GIS(orgURL)&lt;/P&gt;&lt;P&gt;for service in services:&lt;BR /&gt;try:&lt;BR /&gt;# Connect to source and target layers&lt;BR /&gt;fl_source = FeatureLayer(service['source url'], gis)&lt;BR /&gt;fl_target = FeatureLayer(service['target url'], gis)&lt;/P&gt;&lt;P&gt;# get field map&lt;BR /&gt;fields = [[key, service['fields'][key]] for key in service['fields'].keys()]&lt;/P&gt;&lt;P&gt;# Get source rows to copy&lt;BR /&gt;rows = fl_source.query(service['query'])&lt;BR /&gt;adds = []&lt;BR /&gt;updates = []&lt;/P&gt;&lt;P&gt;for row in rows:&lt;BR /&gt;# Build dictionary of attributes &amp;amp; geometry in schema of target layer&lt;BR /&gt;# Default status and priority values can be overwritten if those fields are mapped to reporter layer&lt;BR /&gt;attributes = {'status': 0,&lt;BR /&gt;'priority': 0}&lt;/P&gt;&lt;P&gt;for field in fields:&lt;BR /&gt;attributes[field[1]] = row.attributes[field[0]]&lt;/P&gt;&lt;P&gt;new_request = {'attributes': attributes,&lt;BR /&gt;'geometry': {'x': row.geometry['x'],&lt;BR /&gt;'y': row.geometry['y']}}&lt;BR /&gt;adds.append(new_request)&lt;/P&gt;&lt;P&gt;# update row to indicate record has been copied&lt;BR /&gt;if service['update field']:&lt;BR /&gt;row.attributes[service['update field']] = service['update value']&lt;BR /&gt;updates.append(row)&lt;/P&gt;&lt;P&gt;# add records to target layer&lt;BR /&gt;if adds:&lt;BR /&gt;add_result = fl_target.edit_features(adds=adds)&lt;BR /&gt;for result in add_result['updateResults']:&lt;BR /&gt;if not result['success']:&lt;BR /&gt;raise Exception('error {}: {}'.format(result['error']['code'],&lt;BR /&gt;result['error']['description']))&lt;/P&gt;&lt;P&gt;# update records:&lt;BR /&gt;if updates:&lt;BR /&gt;update_result = fl_source.edit_features(updates=updates)&lt;BR /&gt;for result in update_result['updateResults']:&lt;BR /&gt;if not result['success']:&lt;BR /&gt;raise Exception('error {}: {}'.format(result['error']['code'],&lt;BR /&gt;result['error']['description']))&lt;/P&gt;&lt;P&gt;except Exception as ex:&lt;BR /&gt;msg = 'Failed to copy feature from layer {}'.format(service['url'])&lt;BR /&gt;print(ex)&lt;BR /&gt;print(msg)&lt;BR /&gt;log.write('{}\n{}\n'.format(msg, ex))&lt;/P&gt;&lt;P&gt;if __name__ == '__main__':&lt;BR /&gt;main()&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Jan 2021 22:30:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-solutions-questions/why-is-the-create-workforce-assignments-not/m-p/1015778#M859</guid>
      <dc:creator>Mark_Medina</dc:creator>
      <dc:date>2021-01-11T22:30:05Z</dc:date>
    </item>
    <item>
      <title>Re: Why is the Create workforce assignments not working anymore and how do we work backwards??</title>
      <link>https://community.esri.com/t5/arcgis-solutions-questions/why-is-the-create-workforce-assignments-not/m-p/1015981#M863</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/169928"&gt;@Mark_Medina&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;The Create Workforce Assignments tool was created to work with the original version of Workforce (what we now call Workforce Classic). Projects made before the July 2020 release of will be Workforce Classic, everything newer will be the new version of workforce. Unfortunately, due to the changes made in that release, this script won't work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That being said, there are 2 approaches you could take to get this up and running.&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) Debug the above script until it works (I don't recommend this, as it will probably be quite time consuming)&lt;/P&gt;&lt;P&gt;2) Create a Workforce Classic Project as outlined in the blog below. (Definitely the easier of the two options)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Create a Classic Workforce Project with the ArcGIS API for Python:&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.esri.com/arcgis-blog/products/workforce/field-mobility/create-a-classic-workforce-project-with-arcgis-api-for-python/" target="_blank"&gt;https://www.esri.com/arcgis-blog/products/workforce/field-mobility/create-a-classic-workforce-project-with-arcgis-api-for-python/&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Andy&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jan 2021 16:16:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-solutions-questions/why-is-the-create-workforce-assignments-not/m-p/1015981#M863</guid>
      <dc:creator>AndyShoemaker</dc:creator>
      <dc:date>2021-01-12T16:16:48Z</dc:date>
    </item>
  </channel>
</rss>

