Hello!
New to arcade & pro (and fairly terrible at code). Thank you in advance for you kindness & assistance.
I have pieced together a few things from other posts, but am still having issues. I have a request to replace labels in a map on data I cannot and do not want to edit. I just want to change the acronym used in the data to the desired label.
1) I am currently using the concatenate command, which is working.
Concatenate($feature.FD,'-',$feature.Station)
2) I need to replace the $feature.FD label 'SF&ES' with 'SFD' in that field. When I try the replace command
Replace($feature.FD, "SF&ES","SFD")
It does work but I cannot get the two commands to work together correctly
3) When combined:
Replace($feature.FD, "SF&ES","SFD")+
Concatenate($feature.FD,'-',$feature.Station)
Or in reverse order
Concatenate($feature.FD,'-',$feature.Station)+
Replace($feature.FD, "SF&ES","SFD")
Solved! Go to Solution.
I would set a variable first to pass the new ID and then concatenate:
var label = Replace($feature.FD, "SF&ES","SFD")
return Concatenate(label,'-',$feature.Station)
I would set a variable first to pass the new ID and then concatenate:
var label = Replace($feature.FD, "SF&ES","SFD")
return Concatenate(label,'-',$feature.Station)
Thank you! Super helpful! I was able to return the product quickly without having to dive into the material, which I will start doing. Do you have any recommendations - tutorials, sources?
ESRI training videos were a good starting point for me (Esri Training Catalog | Find Courses on GIS and ArcGIS Topics), just type in arcade! I also browse the community forums to see what others have struggled with and test out code in the arcade playground (ArcGIS Arcade | ArcGIS for Developers).
It's important to note that calling Replace does not actually change the value stored in $feature.FD, so calling that attribute elsewhere will always return the unreplaced value.
To accomplish what you're trying to do, you can either nest your functions, or else use a temporary variable.
var fd = Replace($feature.FD, "SF&ES", "SFD")
Concatenate(fd,'-',$feature.Station)
Or
Concatenate(Replace($feature.FD, "SF&ES", "SFD"), '-', $feature.Station)
Myself, I prefer using variables to keep the code a bit easier to read.
Appreciate you taking the time to provide to options, and the extra information on why it may not change using the replace command! Cheers!