Arcade as a language has steadily grown since its inception, each release finding its way into more and more places in ArcGIS and introducing a steady stream of new capabilities. While the language has evolved, the Arcade editor has largely stayed the same and in a way the language has outgrown the existing Arcade editor as users continue to write increasingly more complex and creative expressions. This has been an area of focus for the team, and we’re pretty excited to show you what we’ve been up to.
With the latest release of ArcGIS Online, we’re introducing a new Arcade editor (where you author expressions) that is built for the future and can grow into your ever-expanding needs. The new Arcade editor is currently used by Map Viewer however, over the next few releases, it will make its way just about everywhere you write Arcade across ArcGIS Online. While parts will look familiar there is much that has changed. So, let’s dive in and look.
Finding your way around
To get started, open the Map Viewer and head over to the pop-up panel and click Attribute expressions. Then click Add expression, or any other place Arcade is supported in the Map Viewer (except for form authoring).
The first thing you’ll notice is you now have much more space to write your expression. This was the most frequently asked request from you as users. We’ve structured the new editor design so that things can easily get out of the way when you need them to, helping you maximize your space.
- It’s important to give your expressions clear and meaningful names, not just so you can find them again when updating your map; the title is used in places like legends and pop-ups to give the expression values meaning and context.
- Clicking the Run button executes the expression and shows you the results. This was previously called Test. It has been renamed to better reflect what the button does and to align better with some future enhancements.
- This is the expression window where you write your Arcade expression and where you’ll find some exciting improvements that we’ll get to in a minute.
- The action bar is a place to browse and access the integrated help as well as all your profile variables (previously called Globals).
Now that you have your bearings lets dive deeper in to look at what’s new with the various parts.
Profile Variables
One of the first things you’ll notice when opening the panel is that profile variables have been renamed from Globals. This change was made to better reflect that these variables while global in nature are defined by the Arcade profile being used (e.g., Labelling, Styling, Pop-ups). They also now contain profile specific descriptions to help you better understand their meaning in in the context of each profile. If you drill into $feature you’ll notice many of the same features as before, but you can now search your fields (also a frequent request from you) and there are icons to denote each field type at a glance. If your field has domains, you can now view and search the domain values to find exactly what you’re looking for quickly. And to get you back to the where you started you can click << to jump to the start of the panel quickly no matter where you were.
Functions
There’s quite a bit about this panel that should look familiar; however, ,we’ve added some things to make your life easier. Functions are now grouped into categories, and in addition to the function name, you have the function’s signature at your fingertips.
If you need additional information, you can dive deeper to get more detailed help along with examples.
Functions that have multiple signatures have now been split out into their own entries in the function list as well making it easier to understand the difference at a glance.
Suggestions
The Suggestion panel consolidates a few different things from the previous Arcade editor into a single panel; Templates and Existing expressions (in the case of Map Viewer). Existing expressions are expressions that are already being used either in the current profile or another profile. These make it easier to copy some or all of an expression into a new one as needed. Additionally, if your profile has Templates you’ll see them in the Suggestions panel too. As the new editor finds its way into other applications, those apps (e.g. Dashboard, Field Maps) can take advantage of the suggestions panel to provide their own context specific examples to help you get started. Look for more exciting things in this panel in the future.
Templates is an area that we want to continue to expand on and look to see more templates to help get you started with common arcade expressions we’ve seen many users author.
Expression window
This is where things really start to get exciting. A significant amount of engineering has gone on behind the scenes that comes to life in the code window. This effort has been driven by several common themes we’ve seen in gathering feedback from you as users.
- Help me write Arcade expressions faster
- Help me better understand errors when they happen
- Help me write better arcade expressions
Help me write my Arcade expressions faster
Intellisense has been the gold standard in code writing for productivity for developers. It puts information at your fingertips, reduces mistakes, quickly stub out snippets and allows you to find what you’re looking for faster than browsing traditional documentation. The Arcade team is excited to announce that the new Arcade editor has Intellisense. This includes functions, constants, profile variables, and more.
Help me write better arcade expressions:
First up is we’ve added more warnings into the editor that allow you to understand when there’s something that in your expression that could be a problem or could be improved. These won’t stop you from saving the expression but something to review.
Some common examples of this might be variables that are not used, or even defined more than once.
Next up, we have automatic formatting. FeatureSets, especially when chaining, can be difficult to read on a single line. With a right click (or the keyboard shortcut) you can quickly format your expression to make it more readable.
Help me better understand errors when they happen
Similarly, with warnings there has been quite a bit of work done behind the scenes to deliver clearer error messages. This, like the warnings, is an area we’ll continue to improve over time.
Run
In the top left corner, you’ll see the Run button. Clicking Run will execute the expression and will show the results in the Results window at the bottom of the editor.
In the Results window you’ll see three panels:
- Output: What your expression returns
- Console: Where you can view information you’ve logged to the console using Console()
- Log: Log provides helpful additional information about the expression execution such as how long it took to execute. This can be helpful to review to make sure you’re not doing too much within an expression to cause delays for your users
Additionally, once you’ve hit run once, you’ll be able to jump back to the last results and see what they were. This can be helpful to review previous results, double check values in the return or even copy and paste values from the return into the expression window.
Output panel
You’ll notice there have been a few changes to the results output. Most notably is that it is now tree-like for complex returns objects (featureSets are still tabular). This allows for quickly expanding and collapsing nested objects without having to jump back and forth between multiple pages in the return window.
We’ve also added color (and quotes for Text) to the Output to help you identify what data type the value is such as numbers, dates, and text and making it easier to copy and paste text values right into your expression if needed.
Data types such as features ($feature is a great example) will now tell you more about the geometry of that feature. This can make it easier to look at the coordinates and spatial reference of the feature you’re working with and facilitate debugging.
What’s next
This has been a major update for the Arcade editor and to go along with it is brand new documentation, so don’t forget to check that out too. There’s still quite a bit on our to-do list for the Arcade editor. Here’s a sneak peak of what we’re working on next.
- Integrate the new editor into the remaining areas of ArcGIS Online
- Continue to grow and expand debugging and testing tools
- Make it easier for 3rd party developers to integrate the Arcade editor into their applications
- Include more templates and examples into the Suggestion panel
- VS Code extension for Arcade
Commenting is not enabled for this article.