I'm creating a web map for Conservation and Heritage features in Lancaster district, UK, and am using Arcade expressions to create hyperlinks to relevant policy web pages and PDF documents. There's 2 or 3 Arcade Expressions that I am repeating in 10 of my layers. As web address and document locations can change I thought it would easier to write an Arcade Expression that could be used repeatedly in different layers.
Is there a way to write an Arcade Expression that can be used for different layers in the same web map? I'm currently copying the same expression into each individual layer, which isn't very time saving or robust as just updating the URL in the attribute tables.
Also, how do people save their Arcade Expressions for using in different projects? I'm new to Arcade and looking for ideas to store useful snippets.
TIA.
I guess something you could do is make a master table of website and Document URLs and then have the Arcade expressions point to that? That way all you have to do is change the URL in the table and it would update everywhere at once.
Regarding saving the expressions: I have mine in text files, as well as saved in each layer in Pro. Be warned that the layer is only for that instance of it; if you remove the layer and re-add it, the expressions will be lost.
I'm undergoing a similar project with multiple corrections of field data on each layer with many layers. Currently just coping and modify for each layer.
I would like to see an ability to write to an expression once and have the option of adding to each layer.
of course, easier said than done...
Hi Christopher,
It's been a few years since I wrote this post! Since then I've started using VS Code for writing and storing my scripts. My GIS projects often have SQL, Python, Arcade and HTML components these days, so I have a folder for each which I can view and edit in VS Code and then copy and paste into AGOL. I save my Arcade expressions as JavaScript files (.js) as that's what it's based on and then the Prettier VS Code extension helps with formatting my scripts. It helps with syntax, but I still need to do all the function lookups in AGOL/ArcGIS Pro.
I find it easier to edit and copy from VS Code than just using the dialog box in AGOL; The side by side windows in VS Code allow me to look at 2 or more scripts, and it has the benefit that I can save my half-finished scripts as a .js file as AGOL doesn't allow me to do that.
"I would like to see an ability to write to an expression once and have the option of adding to each layer."
I can't help with this bit but hopefully Esri will make something more like the Python Window or Notebook, where you have one place to write the code and it can be applied to any layers 🤞🏻
HI doddk,
in the case you described, sounds good. we mostly always work through virtualization software *neglected to mention, that makes this type of solution much more difficult. I too pray ESRI will consider this recommendation🤞