Displaying feedback from geoprocessing service in Web App Builder

4591
1
04-28-2015 09:49 PM
GrantHerbert
Occasional Contributor II

I have a geoprocessing service accessed through a Web App Builder App that appends a parcel to a dataset. I have tried arcpy.AddMessage, print and returning a message through arcpy.SetParameterAsText() but I cannot get it to report that it is finished, or failed.

It is currently asynchronous, and I think that may be why it doesn't return anything, but if I set it to synchronous on the server it fails (SubmitJob error).

Using the ArcGIS Online Assistant I can view the JSON for the web app and I see a setting "isSynchronous": false however setting this to true doesn't fix it as it still tries to SubmitJob (rather than ExecuteTask?).

How can I set up a synchronous service for use in a web app built with the Web App Builder? And how can I return messages to the Web App?

0 Kudos
1 Reply
GrantHerbert
Occasional Contributor II

OK, after some time spent debugging this with the ESRI support team I can update this. The following works (may not be the only way to do it)

arcpy.SetParameterAsText(1, resultMsg) does output the string message that I want to return, however, I was also raising an error via arcpy.AddError in the script (to log to Server logs) and that seemed to interfere with the result passed. If an error is raised then the message is hidden from view (only the "Unable to complete operation" text is shown in the output area in the Web App).

Steps to fix:

Remove AddError from script.

Put the script tool in a model and set the output parameter to a model parameter.

Republish GP service, set to synchronous.

Update widget in Web App (add URL again).

Confirm result string is now available in output area in widget.

The result parameter is now available when the task is run.

In the Web App json the GP service now has outputParams filled in:

          "outputParams": [

            {

              "name": "ResultString",

              "dataType": "GPString",

              "description": "",

              "defaultValue": null,

              "category": "",

              "label": "ResultString",

              "visible": true,

              "required": false,

              "tooltip": "ResultString"

            }

          ],

          "shareResults": true,

          "layerOrder": [

            "Operational Layers"

          ]