Geoprocessing Service with output Feature Layer

358
1
Jump to solution
05-19-2023 10:43 AM
Labels (2)
JillianStanford
Occasional Contributor III

Hello!

I am trying to successfully return a feature layer as the output of the GP service and having absolutely no luck.

I have a very simple python toolbox tool with the following output parameter:

 

out_features = arcpy.Parameter(
            displayName="Output Features",
            name="out_features",
            datatype="GPFeatureRecordSetLayer",
            parameterType="Derived",
            direction="Output")
        
        return [out_features]

 

The main code block looks like this:

 

def execute(self, parameters, messages):
        """The source code of the tool."""
        
        inFeatures = r"D:\Projects\OCTA\LODES\data\Test_GP_Service\Test_GP_Service.gdb\Parcels_SaltLakeSub"
        
        out_fc = arcpy.CreateScratchName("out_features",
                                        data_type="FeatureClass",
                                        workspace=arcpy.env.scratchGDB)
        out_fc = arcpy.analysis.Buffer(inFeatures, out_fc, 100).getOutput(0) 
        
        arcpy.AddMessage(out_fc)
        #parameters[0].value = out_fc
        arcpy.SetParameter(0, out_fc)
        return

 

 

I'm able to execute the tool successfully and publish the results to a standalone ArcGIS Server.

When I submit the job, the logs say that everything was executed successfully and the feature class in scratch.gdb in the related arcgisjobs folder looks correct on the server.

However, when I try and view the contents of the output either using the REST endpoint by submitting a job using Javascript, it is always empty.

JillianStanford_0-1684517454066.png

Somehow, I'm not setting up the output parameter correctly but I can't figure out the trick.

Any ideas are greatly appreciated.

Thanks!

Jill

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
JillianStanford
Occasional Contributor III

In case it's helpful to someone else, changing the output parameter type to "DEFeatureClass" did the trick.

out_features = arcpy.Parameter(
            displayName="Output Features",
            name="out_features",
            datatype="DEFeatureClass",
            parameterType="Derived",
            direction="Output")
        
        return [out_features]

View solution in original post

0 Kudos
1 Reply
JillianStanford
Occasional Contributor III

In case it's helpful to someone else, changing the output parameter type to "DEFeatureClass" did the trick.

out_features = arcpy.Parameter(
            displayName="Output Features",
            name="out_features",
            datatype="DEFeatureClass",
            parameterType="Derived",
            direction="Output")
        
        return [out_features]
0 Kudos