I have a layer of polygons representing land parcels, each of these has a number that identifies it as part of an application, I want the user to be able to select one of these polygons, submit it to a tool and have it return all of the other polygons with a matching application number. It currently runs fine in ArcGIS Pro, but not in web app builder.
This is a snippet of the code that runs in ArcGIS Pro, but I can't get to work as a geoprocessing service within Web App Builder
It basically takes a layer with a selection, determines a value with a search cursor and then uses that value to make a selection based on it to capture all polygons that had that value. This is meant to be used for a data validation sequence, so users aren't manually entering the polygon ID number.
import arcpy
# Get parameters for input
# Existing DID Layer
inputpolygons = arcpy.GetParameterAsText(0)
#tableview="didofinterest"
arcpy.AddMessage("Executing...")
# Determine if a selection has been made. If not, report error.
desc=arcpy.GetCount_management(inputpolygons)
if int(desc[0])>0:
arcpy.AddMessage("Selection found.")
arcpy.AddMessage(f"Found {str(desc[0])} Selections, choosing first")
# Get the first DISP Num of the input table (first of the selection)
with arcpy.da.SearchCursor(inputpolygons,["DISP_NUM"]) as cursor:
for row in cursor:
polynum=row[0]
arcpy.AddMessage(f"Getting {polynum} from {inputpolygons}")
break
# Build where clause
whereclause = """ DISP_NUM = '%s' """ % polynum
# Make a selection.
selected_polygons=arcpy.management.SelectLayerByAttribute(inputpolygons,"NEW_SELECTION",whereclause)
As a script tool it has a single input parameter which is currently set as a Feature Layer type.
When I publish to Portal, the tool has upload capabilities, Asynchronous execution and the message level is set to Info. The input parameter is set as user defined.
When I add the widget into web app builder the single input layer is set to Choose from map.
Running it as a widget causes the app to execute and its output to post to the output screen for a split second and then it clears it, making it nearly impossible to see what is happening. I have managed to determine the geoprocessing widget is not honoring the selection in the web app layer.