I have an ESRI Javascript application that uses a geoprocessing service that uses a cutsom GP tool. Since I have a set of values to be passed to the GP service I am planning to pass in it as a record set instead of string values. These are just attributes and no geometry associated with it. I think I can use FeatureSet in Javascript to pass GP input parameters.
Something like this. Let me know if this is the right way to pass record sets. I will have several records.
var attr = {"OBJETID:1", "Name":"Test", "Address:"Value2"};
var graphic = new esri.Graphic(null,null,attr,null);
var features= [];
features.push(graphic);
var featureSet = new esri.tasks.FeatureSet();
featureSet.features = features;
Now inside the custom GP function tool how do I set the paramaters to read the input? Following is what I am trying to do. Is this the correct approach?
IGPParameterEdit gpParameterEdit = new GPParameterClass();
IGPDataType gpDataType = new GPRecordSetTypeClass();// GPStringTypeClass();
IGPValue gpValue = new GPRecordSetClass();// GPStringClass(); ;
gpParameterEdit.Name = "legal_desc";
gpParameterEdit.DisplayName = "Legal Description";
gpParameterEdit.DataType = gpDataType;
gpParameterEdit.Value = gpValue;
gpParameterEdit.Direction = esriGPParameterDirection.esriGPParameterDirectionInput;
gpParameterEdit.ParameterType = esriGPParameterType.esriGPParameterTypeRequired;
Then while Casting the value, How do I cast and read the values from the input featureset? Following is what I am trying to do and it is returning null for gpRecordSet.
IGPValue gpValue = parameterValueArray.GetGPValue(_parameterIndex);
IGPRecordSet gpRecordSet = (IGPRecordSet)gpValue;
Basically I am trying to see how to pass in set of attributes from JavaScript and read it in custom GP Tool.
Now the return value I expect in the JavaScript application is a polygon graphic and no attributes. What is the best way to return the polygon? What I understand from my research is that I need to create in-memory featurecalss and return the polygon as feature. Is there a better way.
All help appreciated.