I can make more of 100 assignaments on web enviroment
I can make more of 100 assignaments using python scripts for workforce
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
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.