Hi Everyone! I'm new coding and interacting with arcade, during the last weeks I've tried to implement attibute rules in order to make easier the completion of feature attributes guaranteeing data integrity.
However, once I get into this coding environment and from my poor knowledge about it, I've been trying to improve my code to make it more efficient.
Now, I've discovered that I can use just one script to calculate multiple fields, avoiding creating a single calculation rule for each field (I watched this video https://www.youtube.com/watch?v=WsO3v5kDLxg). So with that goal I started to build the code to achieve that multiple calculation in my project, but I failed misserably 🤣🤣🤣.
Not only I barely understand the sample code, I also created my own FrankenCode and even though it didn't throw any error, it doesn't work properly either.
This is the code I made:
var len = $feature.length
var wid = $feature.width
var rad = $feature.radius
if (len != 'nilReason' || wid != 'nilReason' || rad != 'nilReason') {
var len_nr = null
var wid_nr = null
var rad_nr = null
return {
//result is a dictionary or a scalar value
"result" : {
"attributes" : {
"$feature.length_nr" : len_nr, //update field1 in the $feature
"$feature.width_nr" : wid_nr, //update field2 in the $feature
"$feature.width_nr" : rad_nr
}
}
}
}Basically I have 3 main fields (length, width and radius) and 3 secondary fields (length_nr, width_nr and radius_nr), what I want to do is when any of the 3 main fieds is different from 'nilReason', all secondary fields must be calculated as null.
I hope you can help me again...
Thanks a lot.
Eduardo.