I can make more of 100 assignaments on web enviroment

233
5
08-17-2021 03:48 PM
JhonAlexanderAvendañoPaez
New Contributor

I can make more of 100 assignaments on web enviroment

I can make more of 100 assignaments using python scripts for workforce

Tags (2)
0 Kudos
5 Replies
Jcordovafredes
Occasional Contributor

Hello, regarding your question the answer is yes
What? The notebooks are available: anyway I leave you the official (https://github.com/Esri/workforce-scripts)

Now, I modified these codes according to my needs. anyway I leave it available (https://github.com/jcordovafredes/SIG)

Now, I have problems and I still can't solve it.

If you have an ArcGIS Online account, the assignments will work correctly for you, the problem lies in the ArcGIS ENTERPRISE accounts that there is an error specifically in the batch_add that does not allow assignments

Hope this can help you

Greetings

0 Kudos
AaronPulver
Esri Regular Contributor

What error are you seeing @Jcordovafredes on ArcGIS Enterprise? Is it a time out issue?

0 Kudos
Jcordovafredes
Occasional Contributor

Hello

I sincerely do not know the error, since I have been turning for weeks without any results

but when analyzing line by line the error at least for ArcGIS ENTERPRISE lies in the batch_add method

At least I tried in two different accounts corresponding to ArcGIS Enterprise and it threw me the same error, but when doing it with the ArcGIS Online university account, the code runs without any problem.

Jcordovafredes_0-1631111564935.pngJcordovafredes_1-1631111578966.png

 

0 Kudos
Reinaldo_Cartagena
New Contributor II

Hi Jhon. If it is possible to load more than 100 assignments into a Workforce project. One way is to implement Toolbox with Scripts made with the Python API and upload an Excel file with multiple assignments. I have loaded more than 3,000 assignments using a Toolbox in ArcGIS Pro. Attachment sent the Python Sample Scripts.

Example 1:

import shapefile
import types
import pandas as ipandas
import arcpy
import traceback
import arcgis
from arcgis.gis import GIS
from arcgis.apps import workforce
from arcgis.geometry import Point

def loadData (portalConnection, username, project, itemtype, file):
# overwriteOutput
arcpy.env.overwriteOutput = True
# List of assignments to add
records = []
# Read the asssigned from file and loop through the assignned information contained within this file
arcpy.AddMessage("Parsing ...")
arcpy.AddMessage(itemtype)
arcpy.AddMessage(file)
arcpy.AddMessage("Adding ...")
if itemtype == 'Excel File': # get item itemtype: 'Excel File' ...
item = ipandas.read_excel(file)
for index, row in item.iterrows():
# Create assignment in state 0-Unassigned
record = workforce.Assignment(project
,feature=None
,geometry=Point({"x" : row["POINT_X"],"y" : row["POINT_Y"],"spatialReference" : {"wkid" : row["Wkid"]}}) # Create assignment XY
,assignment_type=row["Tipo_asignacion"]
,status=0
,location=row["Direccion"])
# Update assignment attribute
record.assigned_date=ipandas.to_datetime(row["Fecha_asignacion"])
record.due_date=ipandas.to_datetime(row["Fecha_vencimiento"])
record.status=int(row["Estado"]) # state 1-Assigned
record.dispatcher=project.dispatchers.get(user_id=row["Despachador_id"]) # get dispatcher from user_id
record.worker=project.workers.get(user_id=row["Trabajadorcampo_id"]) # get worker from user_id
record.work_order_id=row["Identificador"]
record.description=row["Descripcion"]
record.priority=int(row["Prioridad"])
record.notes=row["Notas"]
# Set attachment
record.attachment_file=types.SimpleNamespace()
record.attachment_file=row["Anexo"]
# Add all assignments to the list created
records.append(record)
# Batch add assignments
batchAdd = project.assignments.batch_add(records)
arcpy.AddMessage(batchAdd)
arcpy.AddMessage("Adding Attachments...")
for assignment in batchAdd:
try:
if hasattr(assignment, "attachment_file"):
assignment.attachments.add(assignment.attachment_file)
except Exception as e:
continue
arcpy.AddMessage("Completed")
else:
arcpy.AddMessage('ERROR getting item from ... '+item)
arcpy.AddMessage("Load data "+itemtype+" completed")
return batchAdd
Tags (1)
0 Kudos
Reinaldo_Cartagena
New Contributor II
OBJECTIDArea_TerrenoAvaluo_TerrenoDimensionEtiquetaRelacion_SuperficieIdentificadorObservacionesManzana_Vereda_CodigoVR_NPN_NUMEROPOINT_XPOINT_YPOINT_ZTipo_asignacionEstadoNotasFecha_asignacionFecha_vencimientoDespachador_idTrabajadorcampo_idPrioridadDireccionDescripcionWkidAnexo
8844289647Dim2D  0341001011003500001 0035050340100001100350001901000001-75.878480915.6593341190Visita_Inicial1Identificador: 0341001011003500001 - VR_NPN_NUMERO: 050340100001100350001901000001 - Area_Terreno: 4 - Avaluo_Terreno: 4289647- Dimension: Dim2D6/10/202120/09/2021rcartagena_gnjavendano_gn0Manzana_Vereda_Codigo:0035 - POINT_X=-75.878480912 - POINT_Y=5.65933411900005 - Wkid=4686Tipo_asignacion: Visita_Inicial - Estado: 1 - Despachador_id: rcartagena_gn - Fecha_asignacion:  - 44475 - Fecha_vencimiento: 44459 -  - Prioridad: 04686D:\Myprofile\Projects\Sectores\National_Government\ANT\PoC_Workforce_2021\Image_File\Anexo_1.jfif
8944289647Dim2D  0341001011003500001 0035050340100001100350001901000001-75.878480915.6593341190Visita_Inicial1Identificador: 0341001011003500001 - VR_NPN_NUMERO: 050340100001100350001901000001 - Area_Terreno: 4 - Avaluo_Terreno: 4289647- Dimension: Dim2D6/10/202121/09/2021rcartagena_gnjavendano_gn0Manzana_Vereda_Codigo:0035 - POINT_X=-75.878480912 - POINT_Y=5.65933411900005 - Wkid=4686Tipo_asignacion: Visita_Inicial - Estado: 1 - Despachador_id: rcartagena_gn - Fecha_asignacion:  - 44475 - Fecha_vencimiento: 44460 -  - Prioridad: 04686D:\Myprofile\Projects\Sectores\National_Government\ANT\PoC_Workforce_2021\Image_File\Anexo_2.pdf
9044289647Dim2D  0341001011003500001 0035050340100001100350001901000001-75.878480915.6593341190Visita_Inicial1Identificador: 0341001011003500001 - VR_NPN_NUMERO: 050340100001100350001901000001 - Area_Terreno: 4 - Avaluo_Terreno: 4289647- Dimension: Dim2D6/10/202122/09/2021rcartagena_gnjavendano_gn0Manzana_Vereda_Codigo:0035 - POINT_X=-75.878480912 - POINT_Y=5.65933411900005 - Wkid=4686Tipo_asignacion: Visita_Inicial - Estado: 1 - Despachador_id: rcartagena_gn - Fecha_asignacion:  - 44475 - Fecha_vencimiento: 44461 -  - Prioridad: 04686D:\Myprofile\Projects\Sectores\National_Government\ANT\PoC_Workforce_2021\Image_File\Anexo_3.jfif
9144289647Dim2D  0341001011003500001 0035050340100001100350001901000001-75.878480915.6593341190Visita_Inicial1Identificador: 0341001011003500001 - VR_NPN_NUMERO: 050340100001100350001901000001 - Area_Terreno: 4 - Avaluo_Terreno: 4289647- Dimension: Dim2D6/10/202123/09/2021rcartagena_gnjavendano_gn0Manzana_Vereda_Codigo:0035 - POINT_X=-75.878480912 - POINT_Y=5.65933411900005 - Wkid=4686Tipo_asignacion: Visita_Inicial - Estado: 1 - Despachador_id: rcartagena_gn - Fecha_asignacion:  - 44475 - Fecha_vencimiento: 44462 -  - Prioridad: 04686D:\Myprofile\Projects\Sectores\National_Government\ANT\PoC_Workforce_2021\Image_File\Anexo_4.jpg
9244289647Dim2D  0341001011003500001 0035050340100001100350001901000001-75.878480915.6593341190Visita_Inicial1Identificador: 0341001011003500001 - VR_NPN_NUMERO: 050340100001100350001901000001 - Area_Terreno: 4 - Avaluo_Terreno: 4289647- Dimension: Dim2D6/10/202124/09/2021rcartagena_gnjavendano_gn0Manzana_Vereda_Codigo:0035 - POINT_X=-75.878480912 - POINT_Y=5.65933411900005 - Wkid=4686Tipo_asignacion: Visita_Inicial - Estado: 1 - Despachador_id: rcartagena_gn - Fecha_asignacion:  - 44475 - Fecha_vencimiento: 44463 -  - Prioridad: 04686D:\Myprofile\Projects\Sectores\National_Government\ANT\PoC_Workforce_2021\Image_File\Anexo_5.jfif
9344289647Dim2D  0341001011003500001 0035050340100001100350001901000001-75.878480915.6593341190Visita_Inicial1Identificador: 0341001011003500001 - VR_NPN_NUMERO: 050340100001100350001901000001 - Area_Terreno: 4 - Avaluo_Terreno: 4289647- Dimension: Dim2D6/10/202125/09/2021rcartagena_gnjavendano_gn0Manzana_Vereda_Codigo:0035 - POINT_X=-75.878480912 - POINT_Y=5.65933411900005 - Wkid=4686Tipo_asignacion: Visita_Inicial - Estado: 1 - Despachador_id: rcartagena_gn - Fecha_asignacion:  - 44475 - Fecha_vencimiento: 44464 -  - Prioridad: 04686D:\Myprofile\Projects\Sectores\National_Government\ANT\PoC_Workforce_2021\Image_File\Anexo_6.jpg
1249810615794Dim2D  0341001011003500002 0035050340100001100350002000000000-75.878613735.6592033830Visita_Inicial1Identificador: 0341001011003500002 - VR_NPN_NUMERO: 050340100001100350002000000000 - Area_Terreno: 98 - Avaluo_Terreno: 10615794- Dimension: Dim2D6/10/202126/09/2021rcartagena_gnjavendano_gn0Manzana_Vereda_Codigo:0035 - POINT_X=-75.87861373 - POINT_Y=5.65920338300003 - Wkid=4686Tipo_asignacion: Visita_Inicial - Estado: 1 - Despachador_id: rcartagena_gn - Fecha_asignacion:  - 44475 - Fecha_vencimiento: 44465 -  - Prioridad: 04686D:\Myprofile\Projects\Sectores\National_Government\ANT\PoC_Workforce_2021\Image_File\Anexo_7.docx
125889532549Dim2D  0341001011003500004 0035050340100001100350004000000000-75.87871355.6590997030Visita_Inicial1Identificador: 0341001011003500004 - VR_NPN_NUMERO: 050340100001100350004000000000 - Area_Terreno: 88 - Avaluo_Terreno: 9532549- Dimension: Dim2D6/10/202127/09/2021rcartagena_gnjavendano_gn1Manzana_Vereda_Codigo:0035 - POINT_X=-75.8787134999999 - POINT_Y=5.65909970300004 - Wkid=4686Tipo_asignacion: Visita_Inicial - Estado: 1 - Despachador_id: rcartagena_gn - Fecha_asignacion:  - 44475 - Fecha_vencimiento: 44466 -  - Prioridad: 14686D:\Myprofile\Projects\Sectores\National_Government\ANT\PoC_Workforce_2021\Image_File\Anexo_8.xlsx
0 Kudos