Hello everyone, with Arcgis PRO and the extract data task tool I have created a web tool to export a FeatureLayer as a zipped shapefile. The web tool only has one argument Layers_to_Clip (object of type GPMultiValue:GPFeatureRecordSetLayer) to identify the FeatureLayer to be exported. When I invoke the web tool I get the error: description: “Invalid value for parameter Layers to Clip - Details : ”
Does anyone have any idea what I'm doing wrong?
I have the following code
async function exportAsShp() {
try {
console.log(`Shapefile export initiated.`);
const query = featureTable.layer.createQuery();
query.where = "1=1"; // Select all features
query.outFields = ["*"]; // Ensure all fields are included
const results = await featureTable.layer.queryFeatures(query);
if (results.features.length === 0) {
console.error("No features found for export.");
alert('No features found for export.');
return;
}
console.log("Number of features found for export:", results.features.length);
// Create a feature collection
const featureCollection = {
layerDefinition: {
geometryType: results.geometryType,
fields: results.fields
},
featureSet: {
features: results.features.map(feature => ({
geometry: feature.geometry.toJSON(),
attributes: feature.attributes
})),
geometryType: results.geometryType
}
};
const inputFeatureSet = new FeatureSet({
features: results.features,
fields: results.fields,
geometryType: results.geometryType,
spatialReference: results.spatialReference
});
const params = {
Layers_to_Clip: inputFeatureSet
};
console.log("Submitting extract data job with params:", JSON.stringify(params));
const jobInfo = await geoprocessor.submitJob(extractDataServiceUrl, params);
console.log("Extract data job submitted. Job ID:", jobInfo.jobId);
const options = {
statusCallback: jobInfoUpdate => {
console.log("Job status:", jobInfoUpdate.jobStatus);
jobInfoUpdate.messages.forEach(message => {
console.log(`Message Type: ${message.type}; Message: ${message.description}`);
});
}
};
const jobInfoCompleted = await jobInfo.waitForJobCompletion(options);
console.log("Extract data job completed. Final status:", jobInfoCompleted.jobStatus);
const result = await jobInfoCompleted.fetchResultData("Output_Zip_File");
console.log("Extract data result:", result);
console.log("Output Zip File URL:", result.value.url);
// Abra o resultado em uma nova janela
if (result.value.url) {
window.open(result.value.url, '_blank');
} else {
console.error("Output Zip File URL not found.");
alert('Error: Output Zip File URL not found.');
}
} catch (error) {
console.error("Error extracting data as shapefile:", error);
alert('Error extracting data as shapefile. Check console for details.');
}
}