Python Script tool's Custom validation doesn't work as a Geoprocessing Service

3236
4
09-01-2015 04:34 PM
AlexisGreen
New Contributor II

I have a script tool for which I've written some simple custom validation that manipulates the user interface of the tool.  It basically updates the choice list in one drop-down menu based on the value the user chooses in another drop-down menu.  The tool validation works when running the GP tool in ArcGIS Desktop, but the validation doesn't work when I publish the script tool as a geoprocessing service and add it to the Geoprocessing widget within the Web AppBuilder.  From the help doc, I gather this may be a known limitation of the software?  If so, does anyone have a suggestion of how to go about implementing custom validation in a web application?  Perhaps by binding the GP service to the Geoprocessing task in the ArcGIS API for JavaScript?  Or maybe there is an easier way?

0 Kudos
4 Replies
FreddieGibson
Occasional Contributor III

I'm pretty sure what you're seeing within the script tool is by design. Once the tool is published to the server the custom validation logic will be removed. I don't really work with WebApp Builder, but if I were to use the JavaScript API I'd handle my tool validate within the client (i.e. on the JavaScript side). Could you provide more information on what your tool validator does?

AlexisGreen
New Contributor II

Good to know.  The way the tool works in ArcGIS Desktop is the user chooses from a list of string values in the 1st drop-down menu, at which point the 2nd drop-down menu dynamically updates its choice list of string values depending on which choice the user picked from the 1st drop-down menu.  Could you give me advice or point me to documentation on how to do this validation in the JavaScript API?  Once the validation is done, I would need to pass the value that the user chooses from the 2nd drop-down menu as an input parameter to my geoprocessing model, which includes python script tools in the model.  The tool doesn't necessarily need to be implemented in the Web AppBuilder; I just thought that might be an easier way to do it than the API.

0 Kudos
FreddieGibson
Occasional Contributor III

I'm more familiar with the Runtime products to access services, so I'll start off by answering how I'd handle this there. I would expect that my validation logic that creates my lists would be removed once I publish the tool to the server. In runtime I'd handle my lists within my runtime application. Let's say I was using Runtime for .NET. Within the .NET client I'd build a control that contains two ComboBoxes. I would use the C# code in my client to control the values shown in these ComboBoxes in the same manner I handled it in my script tool validation logic. The user would interact with the client, which would handle getting the appropriate values to send off in a REST call to my gp server.

I've never really used WebAppBuilder, but I've used the JavaScript API and I'd just take the same approach there. If the values needed can be hard-coded, then I can use any language to present those choices to the user prior to making the REST call. If the values require that I parse the data, then I'd probably have to figure out if my client would allow me to access the data or I'd have to make a service that could kick me back the values I'd need from the data on the server.

Does that make sense?

AlexisGreen
New Contributor II

Thank you - your explanation of the approach makes sense to me, in theory.   It sounds like you have a good deal of development experience.  As I'm more experienced writing Python tools that run in ArcGIS desktop, and a beginner at JavaScript web development, I need to learn how to make what you describe work, in practice.  The values in the choice lists can be hard coded.  Do you happen to have any tips on writing this type of validation logic, as well as how to make REST calls to the GP server, using the JavaScript API?  Perhaps that conversation should be moved to a different discussion area since it would not be about Python anymore.  I appreciate your feedback!           

0 Kudos