My model uses some attributes in a layer for Calculate Fields processes. Example down below is the attribute 'Sp1InvTPA' which is an Integer field. If this attribute is not filled out in the layer before running the model, then the user has the option to enter it as a parameter in the model. Ideally, if this is already filled out in the layer, then the user does not need to enter the parameter, so the Arcade expression looks to utilize it from the layer first, otherwise the parameter will be used instead. If it's not entered in either location, it should remain as Null. The Arcade expression below expects there to be quotes around the Inline Variable name: "%Species 1 TPA%". So, when the user does not fill out the attribute in the layer or the parameter, instead of returning Null, the model thinks the text, %Species 1 TPA% has been entered in the Variable and tries to enter this in the Integer field. Maybe I'm going about this the wrong way. Please help!
Solved! Go to Solution.
That could maybe work. Thanks for the response!
I did just come up with a different way to write the code that seems to work. Instead of checking if the inline variable IsEmpty or !IsEmpty, it's checking if the variable is the name, "%SPECIES 1 TPA%", which would indicate it was left empty, or if it's greater than 0, indicating that an integer was entered. I might have more parathesis in there than necessary.
var Sp1TPA = $feature.Sp1InvTPA;
var Choice = "%SPECIES 1 TPA%";
if (!IsEmpty(Sp1TPA) && (Choice >0)) {
return Choice }
else if (!IsEmpty(Sp1TPA) && (Choice == (Text("%SPECIES 1 TPA%")))) {
return Sp1TPA }
else if (IsEmpty(Sp1TPA) && (Choice >0)) {
return Choice }
else {
return null }
Try replacing the test !IsEmpty("%SPECIES 1 TPA%") with a test on the length of the inline substitution text. An example of finding out the length of text is shown below, you can include similar logic into your code?
var x = "qwerty";
return Count(x);
That could maybe work. Thanks for the response!
I did just come up with a different way to write the code that seems to work. Instead of checking if the inline variable IsEmpty or !IsEmpty, it's checking if the variable is the name, "%SPECIES 1 TPA%", which would indicate it was left empty, or if it's greater than 0, indicating that an integer was entered. I might have more parathesis in there than necessary.
var Sp1TPA = $feature.Sp1InvTPA;
var Choice = "%SPECIES 1 TPA%";
if (!IsEmpty(Sp1TPA) && (Choice >0)) {
return Choice }
else if (!IsEmpty(Sp1TPA) && (Choice == (Text("%SPECIES 1 TPA%")))) {
return Sp1TPA }
else if (IsEmpty(Sp1TPA) && (Choice >0)) {
return Choice }
else {
return null }