Arcade in Pro 2.6 has a new tick trick, and it’s super helpful!

There were several new enhancements to Arcade in Pro 2.6, and you can follow these in the Arcade Release Notes:

https://developers.arcgis.com/arcade/guide/release-notes/

The best news for Arcade users is that it has been expanded into more profiles. The new Dashboard Beta now allows you to control the display parameters of dashboard elements with an Arcade expression. For instance you can cause the test to be larger as the values increase, the colors to become more severe as the situation advances, and of course do on-the-fly calculations to make values from multiple fields. Also, the dynamic text elements in your layouts can now use Arcade expressions. This can be helpful if you need to show a calculated value in the map’s marginalia.

Good stuff … but the one I’m most impressed with is the use of the back tick to make using quoted text easier.

The back tick on most of the keyboards I’ve looked at is on this key in the upper left – under the Tilde. It’s not the same as the single quote mark, even though some fonts have a backward slanting “beginning” quote mark and a forward slanting “ending” quote mark. Quite honestly, it’s a key I’ve never used before and they had to show me where it was.

Now that you can find the key, what does it do? It handles your Template Literals! So what does that mean? Let me explain …

In your Arcade expressions you will come across statements where you are formatting a text string to be returned to the map (or layout, or dashboard, or whatever). This can include text you want to type, values from fields, or even a bit of Arcade code to make a new value. The text is surrounded by quotes, then you put a plus sign, then you add an expression or field, then you put another plus sign, then you can add more text in quotes, and on and on. To use an example from the book, in Exercise 3 you make an expression to calculate the number of houses per square mile, and round that to 1 number past the decimal place. Then to make the resulting label more friendly, you add the text “ units per square mile”. Note that there’s a space before the word units so that in the final display the number doesn’t bump into the text. The expression looked like this:

To use the new back tick process, you put the back tick at the start and stop of the template and encapsulate the field calculation with a dollar sign and curvy braces. Then between the back ticks you don’t need to put any additional single or double quotes to denote literal text, OR include plus signs to concatenate them together. The same expression above looks like this when done with the back tick:

The expression starts and stops with a back tick, the calculation is inside of curvy braces with a dollar sign in front, and the rest is typed as normal text – spaces and all.

This slight change in how the expression is made doesn’t seem like a lot in this example, so let’s look at a more complex expression.

Let’s say y’all wanted to build an expression in a pop-up to show two property line measurements, the difference between them, and add literal text explaining a key characteristic of the calculation. I have a layer with the fields Surv_Dist, Meas_Dist, and Bldg_Setback, and in my pop-up I want to show each of these values in feet, show the difference, and note that the property includes a 22 inch building setback. Like this:

The surveyed distance is 22.9’ and the measured distance is 23.4’ – a difference of 0.5’.

Note that this doesn’t affect the 22” building setback.

This is a nightmare with inch and foot marks, not to mention the apostrophe in the contraction doesn’t and the desire to have the note statement on a new line. That means the literal text that includes a foot mark or an apostrophe must be enclosed in double quotes, and the literal text that includes the inch mark must be enclosed in single quotes. Or you can try the double negative quote thing – which I never get to work correctly. Then to add a new line you need to insert the TextFormating.NewLine constant. This is what the expression looks like – and examine it closely for the use of single and double quotes in both encapsulating strings and representing measurements as well as including spaces in the correct places:

That wasn’t much fun, and frankly I impressed myself that I got the string to format correctly.

So let’s try it with the new back tick process. An interesting thing is that the back tick will recognize a carriage return to go to a new line, so the text formatting constant isn’t needed. In my example I’m going to put the expression on multiple lines by concatenating the pieces together for clarity, but understand that this could be one long expression.

Once you’re inside the back tick you just type away without having to worry about the quote marks, however they are used!

And the Pop-up:

I hope these examples give you an idea of how to use the new back tick in your text formatting, and I hope it saves you tons of headaches.