AnsweredAssumed Answered

Best practices for workspaces for GP Service

Question asked by MollyKFoley on Oct 31, 2018
Latest reply on Nov 1, 2018 by JQuinn-esristaff

I have an eventual GP service that takes an MXD, alters it based on user input, and then exports it to a PDF to return to the user. I know when the MXDs get published to the server, they'll be located in this folder:

C:\arcgisserver\directories\arcgissystem\arcgisinput\PrintService\Print.MapServer\extracted\v101\MyFile.mxd

 

In the script, how should I reference where those MXDs are? I don't think it's best practice to hardcode something like that, is it? If I were to use the below script, would the path "D:\GIS_Testing\...." be replaced with an ESRI variable once it's published to Server? I'm just not sure how to define it so it can find the MXDs once it's up on my server.

 

arcpy.env.workspace = r'D:\GIS_Testing\HabitatDbase\PrintTesting'

#Get the map document to manipulate based on whether the user wants a portrait or a landscape layout map
if orientation == "Portrait":
    mxd = arcpy.mapping.MapDocument(os.path.join(arcpy.env.workspace, 'PortraitLayout.mxd'))
else:
    mxd = arcpy.mapping.MapDocument(os.path.join(arcpy.env.workspace, 'LandscapeLayout.mxd'))

 

For what it's worth, I write the output file to scratchFolder, which I believe is fine:

outputPDF = arcpy.mapping.ExportToPDF(mxd, os.path.join(arcpy.env.scratchFolder, "Map.pdf"))
arcpy.SetParameterAsText(7, outputPDF)

Outcomes