I want to use the calculate field function, to calculate which input comes an expression that should be connected with an output variable.

But I can't figure out how to do so. And if it is possible to do so.

My model looks like this: My model

I use the get field value, to select a field from "soil_type", where I will get one value, that I will put in the calculate field function, so the field in the BS_SJ_Points will have the same value. I have already created a new field in BS_SJ_Points. All fields data_types is double.

%%% UPDATE %%%

So I have changed the model, and now it looks likes this:

enter image description here

And it almost works. When I run the model through the edit mode, the model works and I add a new field to my shapefile with the wanted information.

As you can see, I have set up parameters, so the end user shouldn't go to the editor to make the model work but can just double tap the model and set the necessary parameters. When I try to run the model that way it is the wrong output I get. Either it is 1 or it is the value from when I run it in editor mode.

I assume there is something wrong with my field parameter or the information in the get field value function. So what can I do to fix it, so you can run the model without entering editor mode?

  • If your updated model is truly all that there is then you need to make the output of get field value a precondition to the calculate field tool, this ensures the correct order of operations
    – Hornbydd
    Nov 25 '18 at 16:15

If you look at the screen shot the connecting line is dotted, this is telling you that it is being treated as a precondition.

Think about what you are connecting, a value, to a tool that is expecting an expression, this is what the syntax section of the Help file is telling you. You are trying to put "a large square peg into a small round hole"!

So to pass the value from Get Field Value tool you use inline substitution. The output of that tool is currently called Infiltration_Rate, you could have named it anything. To reference that you enclose it in %%. So in the expression part of the calculate field simply type in %Infiltration_Rate%, do not try to connect the output of Get Field Value to Calculate Field as they are different parameter types. Again I refer you to the syntax section of the help file for any tool, this helps you understand which tools can be connected.

  • Hi Hornbydd. Thanks for the help. Your help made it work - almost. Please read my update, and see if you can help me.
    – N.Juul
    Nov 24 '18 at 13:55

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.