Skip to main content

“Arcade’s Fire: Inside Esri’s Scripting Language” Webinar Q&A – Part 1

We keep the car running by answering your questions about building expressions with Arcade.

Hello World! (coding joke)

Thanks for attending the “Arcade’s Fire: Inside Esri’s Scripting Language” webinar on February 11, 2021. If you missed it, you could view the recording and download the slides on demand. Mark Ho and I hope you enjoyed our spin on classic video games and learned something about coding with ArcGIS Arcade along the way.

Loads of questions came streaming in throughout the presentation so we took the time to go through and answer them as best we can and split the blog post into a 2-part series. In Part 1, I have replied to your general Arcade questions and cleared up some remaining questions regarding the Visualization and Attribute Rules profiles. If you’re interested in clarifications about the Labelling and Popup profiles, watch out for Part 2 which will have some great insights by Mark.

Don’t forget, we created an ArcGIS Online group that compliments the webinar. You can access the group at: bit.ly/arcadesfirewebinar (all lower case)

Our ArcGIS Online group includes supplemental resources from this Arcade webinar.

It contains web maps and sample code from our demos, downloadable ArcGIS Pro projects and other useful resources. And there’s more to come. Stay tuned!

Finally, Mark and I shared our mutual love for the band Arcade Fire.

Emilie’s view of Arcade Fire during their Infinite Content tour in 2017.

In that light…

From the sprawl of the suburbs to places where no cars go, many tuned in to our webinar and asked lots of great questions. We exist to answer everything now. Wake up! Let’s get ready to start!

General Questions

Many questions were asked about Arcade’s position in the ArcGIS system and the structure and syntax of the scripting language.

Q: Will Arcade replace other programming languages I use like Python or JavaScript?  If not, what is the advantage of using Arcade?

A: Have no fear, Python and JavaScript aren’t going anywhere. Arcade is not intended to be a replacement for automation and geoprocessing tasks that can be completed using Python. It’s also not a standalone language intended for building apps or for executing expressions within other apps that are not supported by ArcGIS.

Then what is Arcade intended for? Arcade is a simple and lightweight language that is to be used for evaluating the values of attribute fields and geometries within the context of apps authored by another ArcGIS product like ArcGIS Pro, ArcGIS Enterprise, ArcGIS Online or the ArcGIS API for JavaScript.

Q: What version of ArcGIS Pro is needed to use Arcade?

A: The following matrix indicates the version of Arcade installed in each version of ArcGIS Pro. For additional details, including known limitations for the version of the ArcGIS product you use to consume and author Arcade expressions, please visit the ArcGIS Pro documentation. You can also review release notes for each version of Arcade.

Q: What version of Portal for ArcGIS is needed to use Arcade?

A: The following matrix indicates the version of Arcade installed in each version of Enterprise portal. For additional details, including known limitations for the version of the ArcGIS product you use to consume and author Arcade expressions, please visit the Portal for ArcGIS documentation. You can also review release notes for each version of Arcade.

Q: What version of ArcGIS Server is needed to use Arcade?

A: The following matrix indicates the version of Arcade installed in each version of Enterprise server. For additional details, including known limitations for the version of the ArcGIS product you use to consume and author Arcade expressions, please visit the ArcGIS Server documentation. You can also review release notes for each version of Arcade.

Q: Where can I find a reasonably comprehensive reference for Arcade functions and syntax?

A: The best place to start your Arcade journey is with the documentation. Use the Arcade Function Reference page to get familiar with the entire library of functions. Whether you are working with data or date functions, formatting text or performing mathematical operations, the logical (😉) first step always includes the documentation.

After exploring the possibilities built-in functions can offer, you’re probably feeling inspired to start writing your own Arcade expressions. The Structure and Logic document will answer questions you have regarding scope, operators, variables and so much more so you can start scripting with ease.

Q: Can I reach out to Technical Support if I’m having issues with my Arcade expressions?

A: Yes! The Esri Canada Technical Support team is there to help and that includes giving you a hand with an Arcade expression that’s seemingly impossible to debug.  Before logging a case with the tech support team, consider checking out these forums for some help. Someone may have come across a similar issue.

Q: What’s the best way to debug an Arcade expression?

A: Great follow up question. During the webinar, a lot of the code we shared worked flawlessly on the first try. Truth is, we spared you from the long process of testing and debugging. Your two secret weapons can be found within the expression window – Test and Results.

The Results panel will tell you what the expression is trying to return in your map. If the type or resulting value isn’t what you expect, here are three things you can do:

  1. Investigate each line in your expression.
  2. Use the return statement for each line along the way to make sure you are getting what you expect in each step.
  3. Comment out any code, use // before anything you want the expression to ignore.

You can also use the small pencil symbol to the right of a field to change the value being used in the test. By default, it pulls the first record from your table. But if you want to test what the result will be for other scenarios, you can simply type in a different value.

Another way to see what the expression is returning at different points in your expression is by using the Console() function. This is almost like a print statement in other coding languages. The function will log a message in the Messages window for debugging purposes.

Over the next year you can expect to see improvements within the Arcade web editor and this includes better testing and troubleshooting capabilities. Keep an eye out for that!

Q: Will Arcade be available in ArcMap in the future?

A: ArcGIS 10.8.1 is the current release of ArcMap and will continue to be supported until March 1, 2026, as established in the ArcGIS Desktop Product Life Cycle. There are no plans to release an ArcMap 10.9 with the ArcGIS releases in 2021. For that reason, if you are interested in leveraging some Arcade functionality in your desktop GIS, Esri has curated lots of resources to ease your transition from ArcMap to ArcGIS Pro. You can read up on ArcMap continued support here.

Q: What sort of services is Arcade compatible with?

A: Arcade is implemented into different parts of the product and the scope of Arcade will continue to expand. As more products are released you may see the footprint of Arcade expand. To get a sense of where Arcade can be executed check out the documentation on Arcade profiles. A profile is a context in which an Arcade expression is evaluated and understood. Each profile expects specific inputs and output types depending on the use case.

Q: If-Else, IIF, When - Oh My! Which conditional statement should I use?

A: If you’re currently grappling with the logic of your function this is a great question to be asking yourself. There are a few things to consider in your decision making. Start by using the syntax that makes the most sense for you. If you are less comfortable with the syntax of Arcade, try using the IIF() or When() functions. Here are a few ways to work with conditional statements in Arcade:

If-Else logic

This method uses syntax that looks just like JavaScript, where you write your condition in the parentheses and you tell the expression what to return in the squiggly brackets. For example:

IIF() function

IIf(condition, trueValue, falseValue) return {*}

This built-in function does the same thing as the code above but doesn’t require you to write out the code syntax. This could be an easier way to start if you aren’t comfortable with coding. In the first position, you write the conditional statement. In the second position, you tell it what to return if the conditional statement is met (if true). And in the final position, you tell it what to return if the conditional statement is not met (else). For example:

When() function

When([expression1, result1,…expressionN, resultN], default) returns {*}

This built-in function is helpful when you have many different conditional statements. This works like the IIF() function, except you can include as many conditional statements as you need for your calculation. For each conditional statement, you tell the function what you want it to return for each condition.

If you are interested, view these different code snippets in action in the following web map.

Q: Can a number variable be returned as an integer instead of float? i.e., 12 vs. 12.543533

A: Arcade was built with simplicity in mind. For that reason, numbers are a single data type. They can be integers or a floating-point value. They can even be string values resembling numbers that can then be cast using the Number() function.

Q: Can Arcade be used in ArcGIS Field Maps­?

­­­­A: Yes! You can use Arcade expressions to calculate entries on-the-fly when team members are out collecting data using Field Maps. You can calculate entries based on formulas and other parts of the form you have configured. For more examples, see the documentation

Visualization

Since Arcade allows you to transform your data values on-the-fly, you no longer need to calculate and re-calculate a new field until you get it just right. Arcade allows you to generate new values and create compelling visualizations without ever leaving your map.

Demo example of using the Visualization profile to generate unique values to symbolize a map on-the-fly using calculations and conditional statements. [view demo web map]

Q: Is it possible to display related table records in a web map? For example, I have a feature layer with hydrants and a related table with hydrant maintenance records. 

A: Each profile expects specific input and output types depending on the use case. The visualization profile, for example, only supports the $feature and the $view.scale globals. Accessing related records requires the use of the FeatureSet object, which is only available for the Attribute Rules, Popup and Field Calculate profiles. Head over to Mark’s blog post where you can learn more about how to access related tables through popups.

Q: Can I use Arcade to visualize time enabled data?

A: Absolutely! Arcade has several out-of-the-box date functions that simplify the process of visualizing time enabled data. Functions such as DateAdd()DateDiff()toUTC()Hour()Weekday() and others are available for your convenience when exploring and displaying time data. Check out this blog post for great examples.

Q: How does the $view.scales global work?

A: We didn’t get the chance to cover the $view.scale global during the webinar. This global can be used to allow your symbol to adjust accordingly as your viewer zooms in and out of your map. The $view.scale global works by returning the scale of the map at the time the expression evaluates. If you’re familiar with map reference scales in ArcGIS Pro, the $view.scale global can provide a similar functionality. To see how the global is used to fix the size of symbols to a desired height and width at a specified scale head over to this StoryMap for more details.

Q: Can I combine multiple Arcade expressions to visualize my data?

A: Yes, you can! Relationship maps provide the ability to visualize and compare multiple attributes from your data. The same applies to values you calculate on-the-fly with Arcade. The following map displays the change in total vehicular accidents in Ottawa between 2018 and 2019 using a combination of two Arcade expressions.

The first expression returns a string value for a unique value visualization to display whether a neighborhood had more or fewer collisions. The second expression returns a number value to achieve the varying size of symbols in the map to indicate larger spikes in vehicular accidents.

Attribute Rules

Attribute rules enhance the editing experience and improve data integrity for geodatabase datasets. They are user-defined rules that can be used to automatically populate attributes, restrict invalid edits during edit operations and perform quality assurance checks on existing features. The possibilities are incredible! They are easy to set up and can really speed up your editing workflows.

Demo example of using the Attribute Rules profile to trigger a user define error to ensure the right information is captured during an editing workflow [Try it out for yourself]

Q: Are attribute rules supported in ArcGIS Online?

No! Currently, attribute rules are not supported in hosted feature layers in ArcGIS Online.   

Q: Where can attributes rules be created?

The Attribute Rules view can be opened from the following locations:

  1. Catalog pane—Right-click a feature class or table and click Design > Attribute Rules.

2. Contents pane—Right-click a layer or table and click Design > Attribute Rules

3. Ribbon—Select a layer or table in the Contents pane. On the Feature Layer contextual ribbon, click the Data tab and click Attribute Rules in the Design group.

Q: Do attribute rules work with ArcGIS Field Maps?

Using ArcGIS Field Maps to edit a layer that has attribute rules will trigger immediate calculation and constraint rules on the server. But editing an offline map will not trigger these types of attribute rules until the edits are synced.

Q: Do attribute rules work in a disconnected workflow with ArcGIS Field Maps?

Not yet! Attribute rules are coming to hosted feature services and to forms so that you can execute business logic in your form connected or offline.


Didn’t find the answer you were looking for? Keep an eye out for Part 2 of this blog where Mark will review your questions about the Labeling and Popup profiles. Mark and I appreciate your interest and your curiosity. Have fun with Arcade – it really is fun!  Happy coding!  We are cheering you on!

This post was translated to French and can be viewed here