Select to view content in your preferred language

Server Geoprocessing Tool with Dynamic Input Parameter

683
4
10-04-2024 07:11 AM
Layth
by
Occasional Contributor

I have created a custom Python Toolbox tool with an input parameter where the options are loaded from an attribute in a table in an Enterprise Geodatabase.  The parameter is of type GPString.  And the list of choices is generated in the updateMessages method.  Like this:

with arcpy.da.SearchCursor(projects, "ProjName") as rows:
    parameters[0].filter.list = sorted(list(set([row[0] for row in rows])))

All works great as a tool in Pro.

When I publish the tool to ArcGIS Server, it still works.  However the list of choices is now fixed.  If I add a record to the table in the EGDB, the new item is not provided as an option in the tool.

Is there a way to keep this dynamic as a server tool?

 

0 Kudos
4 Replies
DEWright_CA
Frequent Contributor

Do you have the DB registered as a DataSource in your ArcGIS Server? If you don't when the script is published it will snapshot the table.

0 Kudos
Layth
by
Occasional Contributor

It is registered with the server, yes.

0 Kudos
DEWright_CA
Frequent Contributor

Do you have the option set in your AGS machine machine in the "Site" area to "Allow data to be copied to the site when publishing services." under the settings button? 

If you make sure this is unchecked; it should avoid the publishing process from creating a cached/feature-table.

0 Kudos
ModyBuchbinder
Esri Regular Contributor

I do not think validation code goes to server in anyway.

The input to the tool should be simple string.

You should write code to give dynamic choice list in the client. If you run it from Pro you can warp the gp service with local tool that will call it. If in JavaScript you should write the dynamic UI yourself.

Have fun

0 Kudos