I have a model, that I created a routing service from. I use the following tools in the model: Make Route Layer Add Locations Solve Add Field to Analysis Layer Select Data

I need a unique identifier each time the model is run in async mode, to be associated with that particular job (or execution). I added a field called RouteId to the Network Analyst Layer (or resulting "Route" layer). I made this "name" a model parameter. When I execute the service from my C# code, I can assign a value to the "name" of the field, but I can't find a way in the code to place a "value" in that new field. Here is a snippet of the code that I am using:

//Create a new GP String with parameter name of RouteId                
 GPString gpIdString = new GPString("FieldName", "RouteId");
 ExecuteAsyncMethod(gp, parameters);

Once it goes into the gp.GetResultDataCompleted method, I can get at the field "RouteId" but the value is null.

How can I put a value into the RouteId field?


I was able to resolve this by adding the GP tool "Calculate Field" after adding the field to the resulting Route layer. By using the "Expression" of the Calculate Field tool as an input parameter, I was able to change the value of the field RouteId.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.