Arcade to change value in specific field for visualization when condition met

349
1
09-22-2020 05:09 PM
MattTarkington1
New Contributor II

Hey there,

I'm trying to get arcade to replace the value in one field when the value in another field is changed.

I get no errors in my script, but am uncertain if arcade is capable of this type of action, collector is capable of this, or if I'm using the correct function. What I've got so far is as follows:

iif($feature.Gun == 'nogun', Replace($feature.Mount, 'haspost', 'removepost'), Replace($feature.Mount, 'haspost', 'haspost') );‍‍‍‍‍‍‍‍‍‍‍‍

For a little bit of context here the 'gun' is referring to snowmaking equipment and 'post' is referring to a location that we can place snowmaking equipment. Locations are permanent. I have a view layer that only visualizes the "Gun" field which has a list of values: No Gun, 4 Step, 7 Step, Millennium. 'No gun' has no visualization. Other gun values have unique Icons. A second view layer visualizes the $feature.Mount  whose list of values are: Mount, Has Post, Needs Post, Remove Post. If a gun is selected it will cover the mount visualization. 

So what I'm trying to accomplish here is that when our field technicians need to move a snowgun in the field they only have to change the drop down for $feature.gun to "No Gun" to change the visualization of $feature.mount to "Remove Post", and the visualization is changed automatically to convey information to the rest of the crew. Our guys use collector in the field.

I realize that there will need to be more conditional statements to get the end product I described above (for instance 'No Gun', and 'Needs Post' are a combination I'll need to account for. I'd just like some input as to whether i'm barking up the wrong tree here or not. 

Thanks yall, I hope this was a clear enough explanation of my problem.

0 Kudos
1 Reply
XanderBakker
Esri Esteemed Contributor

Hi Matt Tarkington ,

Have a look at the expression below, and see if this gets any close to what you are looking for:

var Gun = $feature.Gun;
var Mount = $feature.Mount;

var result = "";
if (Gun != "nogun") {
    result = Gun + " (" + Mount + ")";
} else {
    result = "Remove Post";
}

return result;

Some test results:

var Gun = "7 Step"; 
var Mount = "Has Post"; 

Will result in:

7 Step (Has Post)

var Gun = "Millennium"; 
var Mount = "Needs Post";

Will result in:

Millennium (Needs Post)

var Gun = "nogun"; 
var Mount = "Mount"; 

Will result in:

Remove Post
0 Kudos