list values from field as input for geoprocessing service in web app

660
2
12-28-2020 04:16 AM
OrrGvili
New Contributor III

Hi 
I have python toolbox  that populate one of the inputs from values in field, works great in pro 

is there way to make this work in with geoprocessing service in webapp 
when I publish the tool i get constant list of values 

2 Replies
BlakeTerhune
MVP Regular Contributor

Are you intending that users choose one (or many) field name values from this input?

0 Kudos
JohannesLindner
MVP Frequent Contributor

I'm not the OP, but I've got the same problem...

The idea isn't to choose a field name, but the field value.

For example, imagine a tool that exports data from a user-specified row to Excel. The user opens the tool and sees a dropdown list of existing values in a field of the table, eg permit codes or parcel numbers. In the python toolbox, you can populate that list with something like this:

class Tool:
    def getParameterInfo(self):
        p0 = arcpy.Parameter(...)
        with arcpy.da.SearchCursor(layer_or_table, [field]) as cursor:
            p0.filter.list = [row[0] for row in cursor]
        return [p0]

Each time you start that tool in Pro, it searches the specified layer/table for values. If you add a new value, it will be shown in the dropdown list the next time you start the tool.

When you publish that tool, you get a static list of values that were in the layer/table when you published. New entires won't be shown.


Have a great day!
Johannes