I have an ExportExcelFile geoprocessing service developed in ArcPy and I want the user to get the download file URL returned so that they can click on the link and download the Excel file. The geoprocessing service is called from a Portal Web App Geoprocessing widget. I can get the string result but that needs to be copied and pasted into another browser tab to work. I just want the user to click on the download URL link. I am returning an output parameter of type "File" but only getting an object [object] in the results. Here is the code:
Solved! Go to Solution.
I have solved the issue. The GP service output should be of type "File". The user can click a link and the zip file downloads. The Portal arcgisjobs folder is used for the shapefile and the zip file. Code to follow:
Have you set the Parameter as Output and 'Derived'? Because you're saving to a known location, the tool doesn't have a traditional output to serve.
Yes I have done that. I am now looking at the urllib2 module.
Maybe you should return "vOutputFile" instead of "aFile" in the SetParamter function.
I did try that but just get object [object] back from the geoprocessing service in Portal. I will solve this and post the solution but it may be tomorrow.
I have solved the issue. The GP service output should be of type "File". The user can click a link and the zip file downloads. The Portal arcgisjobs folder is used for the shapefile and the zip file. Code to follow:
Glad you figured it out. I am working on a similar gp service where the user selects a layer in the first parameter and provides a string for the name in the second parameter. A shapefile and kmz are created from that layer and returned to the user. I am experiencing this issue described below.
I'm not sure if you are doing the same workflow, but it sounds similar. If you are, can you tell me if you're running into that same issue?
Thank you! I've done this several times and it worked but this time I forgot to change it and it stayed at the default "String". You've saved me much frustration.
I'm only returning one output file, are you returning two? A shapefile and a KMZ? Maybe you need 2 output parameters, one for each file type.
That's right I am returning two files through two SetParameterAsText parameters. I have no trouble returning each file, but it's more like the call from gp widget to gp service gets stuck on the first arguments passed when using the same layer. I assume in your workflow the user could filter a layer in the attribute table, select that layer in the gp widget, and it will only export data for what was filtered. Is that correct? If so, could you run that, then go filter the same layer again and run the gp widget again? I'm curious if your data will update to reflect the filtered changes.