Nobody an idea? No one using Python geoprocessing services that return features to clients like ArcGIS Pro? From my understanding this should be a common task.
My process successfully creates a feature class from my third party data but I'm still unable to return this feature class in a way from my service, so that clients like ArcGIS Pro add them as a new layer to the active map.
search_results = arcpy.Parameter(
displayName="Search Results",
name="search_results",
datatype="GPFeatureRecordSetLayer",
parameterType="Derived",
direction="Output")
srs_etrs89 = arcpy.SpatialReference(25832)
search_fc = arcpy.CreateFeatureclass_management(scratch_db_path,
"search_results", "POLYGON",
"", "DISABLED", "DISABLED", srs_etrs89)
fields = ['text', 'typ', 'score', 'bbox'] # Only use common bkg fields
search_results_cursor = None
for index, feature in enumerate(result_features, start=0):
if index == 0:
for field in fields:
arcpy.AddField_management(search_fc, field, "TEXT")
fields.append('SHAPE@')
search_results_cursor = arcpy.da.InsertCursor(search_fc, fields)
self.write_feature_row(search_results_cursor, feature, srs_etrs89)
del search_results_cursor
parameters[1].value = search_fc