Hi all,
I am looking for some help with a calculated value in Field Maps. My very limited Arcade is letting me down and any help would be appreciated.
Background
Form order sees the following:
Rules:
The form element for IsHabitable has conditional visibility for BuildingType == Residential
Questions:
The calculated value has conditional Editing allowed with a switch value so users can override the calculation.
Solved! Go to Solution.
Here is an example. For this, I start with single conditions and return the function based on that. If it doesn't meet the logic of the if statement it passes to the next logic. Finally if all non-applicable or non-habitable conditions are passed, it return habitable.
//handles non-residential buildings and returns not applicable
if($feature.BuildingType != 'Residential'){
return 'Not Applicable'
};
//if it is "Residential" will check for damage and return val
if($feature.Damaga == 'Severe' || $feature.Damage == 'Destroyed'){
return 'Not Habitable'
};
//if the building is residential and the damage is not severe or destroyed will return this vallue
return 'Habitable'
Here is an example. For this, I start with single conditions and return the function based on that. If it doesn't meet the logic of the if statement it passes to the next logic. Finally if all non-applicable or non-habitable conditions are passed, it return habitable.
//handles non-residential buildings and returns not applicable
if($feature.BuildingType != 'Residential'){
return 'Not Applicable'
};
//if it is "Residential" will check for damage and return val
if($feature.Damaga == 'Severe' || $feature.Damage == 'Destroyed'){
return 'Not Habitable'
};
//if the building is residential and the damage is not severe or destroyed will return this vallue
return 'Habitable'
Misspelled "Damage" on line 6 and didn't catch it until after hitting post. 😥
I would write it more traditional like this. easier to follow.
if($feature.BuildingType != 'Residential'){
//handles non-residential buildings and returns not applicable
return 'Not Applicable'
}
else if($feature.Damaga == 'Severe' || $feature.Damage == 'Destroyed'){
//if it is "Residential" will check for damage and return val
return 'Not Habitable'
}
else {
//if the building is residential and the damage is not severe or destroyed will return this vallue
return 'Habitable'
}
@DougBrowning thank you. This is how I would think as well.
Adding the "else if" as statements is definitely probably more technically sound and has a better readable flow. I just didn't do it in my example to really flesh out each logic check as it's own entity for the sake of understanding how the code executes.
@AustinAverill thank you so much for your help.
Turns out I was completely over-thinking everything.
Not only that, I was using string values for an integer based domain. The working code is listed below. Thank you again.
Ahh, yes. Forgetting something is on a integer coded domain will be a hinderance every time! 😂