Python scripts and Web Geoprocessing Service

533
4
11-23-2022 04:55 AM
adminCentlec
New Contributor III

I am trying to inform the user about what is going during a GP tool run in my web application. I have used AddMessage and other variations of this, but it is not working, the user is not informed. This is a critical final step in order to make the user aware of the results. 

 

Is there a different way through python to inform the user as the GP tool runs or when it is complete? As I said, all messages are ready, just that they are not appearing in the output pane of the geoprocessing window. 

0 Kudos
4 Replies
Bheist_esri
New Contributor II
You'll have to use arcpy.AddMessage() in the script used to publish the GP Service and also set the Show Messages service property to return the level of messaging.
0 Kudos
adminCentlec
New Contributor III

Thanks, I have done this but GP service output just shows the messages for a split second and then removes/hides them. This is quite perculiar to be honest and I am not sure why it does this. On your side do the messages remain in the output pane or they also appear for a split second?

0 Kudos
Bheist_esri
New Contributor II

I think that may be something the you'll need to customize with the GP Widget. I found this other Community Post that should get you pointed in the right direction.

https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/wab-how-do-i-customize-output-...

adminCentlec
New Contributor III

Perhaps there is a timestamp used to display the message so that it does not flicker, but the suggestion above also does not work. Please see below ammended script. And I have checked that the GP parameters to return all Warnings. 

# Get the number of affected Households/Parcels
countSelectedFeatures = getCountOfSelectedFeatures(cadastreSelectLayer)
arcpy.AddWarning("Feeder ({0}) in transformer ID {1} will affect {2} Parcels/Households out of {3} household(s)".format(selectedFeederID, transID, countSelectedFeatures, householdNumber))

# Delete the point layer created in order to restart the whole process
arcpy.DeleteFeatures_management(pointLayer)
print (result.GetMessages())
print (arcpy.GetMessages(2))
print (arcpy.GetMessages()) 

 

0 Kudos