Server: SetParameter always writing to scratch (I don't want that!)

11-09-2016 02:58 PM
Occasional Contributor

I've written a geoprocessing script which takes a user drawn AOI from the webmap, does some stuff, then outputs a PDF. The geoprocessing service is accessed through the geoprocessing widget in WebAppBuilder.

The pdfs are written to/stored in a specific directory on our file server as they need to be retrieved for use later through a popup which shows a link to that file (i.e. user clicks on an extent polygon generated each time the tool is run. This shows a popup which gives the details of the PDF map and contains a link to that PDF). In other words, the PDFs are not temporary so writing them to the scratch directory on the server is no what I want to do.

My issue is, no matter what I try I can't get the output parameter to properly display the link- When the geoprocessing tool finishes through the widget, it displays the link as <HostServer>/arcgis/rest/directories/arcgisjobs/geoprocessors/<geoprocessorName>/<JobID>/scratch/<MyFile.pdf>.

The link that I set to the output parameter is (for example):


The link/location is valid because

a) It is available from the server

b) When running the tool before publishing, an addMessage line I've put there gives a string I can paste and access the pdf

c) After the service geoprocess is finished, you can click on the extent polygon and access the pdf through the link written to the attribute table.

No matter what I try I cannot get that link to show as the output parameter after publishing/running as a service! I've tried setting the workspace to my output location in the script and in the environment settings, not setting it etc etc.

I can't paste screen shots as it's on a disconnected server but:

the relevant python is:

out_PDF = os.path.join(out_folder, 'exampleName.pdf)

arcpy.AddMessage("Exporting PDF: %s" %(out_PDF))

arcpy.mapping.ExportToPDF(mxd,out_PDF,data_frame = "PAGE_LAYOUT"

arcpy.SetParameter(9, str(out_PDF)

In the tool parameters, parameter 9 is 

Data Type: File

Type: Derived

Direction: Output

MultiValue: No



Filter: File (.PDF) though have tried this as blank

Obtained from:

Any help would be really appreciated as its been pretty frustrating trying to get something which seems like it should be so easy to work! I just need to display a line of text as a link!

0 Kudos
2 Replies
Occasional Contributor III

The idea behind a geoprocessing service is that your input data are being transferred to the ArcGIS Server machine where they are processed by geoprocessing and/or custom script tools. The result of this work is being temporarily stored within the arcgisserver directory called arcgisjobs. For each run of the GP service, a folder with an unique GUID name is being created where the file with the printed layers is created.

My recommendation will be to add an "advice" to the widget.html to your users on where to save the output manually or run a .bat script (task schedule) that will run twice a day to copy (not replace) to your specified folder.


0 Kudos
Occasional Contributor

Thanks Baba,

That seems like a very round about way to do what I need. I understand how it 'wants' to work, my issue is that that way (i.e. a temporary file) doesn't fit what I need to do (i.e. a repository of outputs). 

It's a bit frustrating...I can set the output parameter to a text string representing the proper link to the PDF fine  (which doesn't show as a clickable link) but as soon as I change that parameter type to file, it also changes the link to the incorrect location.

What's interesting is that another script I have which does a similar thing (i.e. does some geoprocessing, returns a PDF map) DOES work. I've checked everything in detail to compare but this one refuses to cooperate.

0 Kudos