Select to view content in your preferred language

Using an Arcade expression and two text attributes to create unique value symbology in Enterprise Map Viewer

694
4
09-01-2023 09:14 AM
JayHodny
Regular Contributor

Hello!  I continue to build a cart management application in the wildly exciting space of refuse carts.  We are using the new Map Viewer in ArcGIS Enterprise 10.9.1.  I am trying to create unique feature symbology using an Arcade expression.  The overall workflow is initiated on the office admin side (enter cart type and size requested by transaction type) using Survey123 Connect forms embedded in Experience Builder.  The survey records are updated in the field using Field Maps smart forms (cart size delivered and the serial number of the cart). 

Here is the breakdown of refuse cart variables (all are type=text variables): Transaction type [new carts, replace carts, second carts, and return of carts], Cart type (trash, recycle, yard waste], and Cart size [large, small].  I am trying to use Arcade to create unique symbology based on the six combinations of cart type and size (trash small, trash large, recycle small, recycle large, yard waste small, yard waste large).  I have found useful posts, for example, How To: Group Unique Values from Multiple Attribute Fields Using Arcade Expressions in Arc (esri.com...  Unfortunately, I was not successful using the example code in this article. 

In my Survey123 Connect XLSForm, the cart type question is select_multiple from a list of three cart_type choices (trash, recycle, yard waste), as each Transaction type can include any one, any two, or all three cart types.  The cart_lgsm size question is select_one from a list of two choices (small, large).  I am assuming one issue might be the select_multiple cart type question in the Survey form and my Arcade code expecting a single response.  For example, if cart_type==trash, and cart_size==small, return 'smalltrash' won't work if the response was 'trash, recycle' to the cart_type question.

My Arcade skills are beginner level.  In my mind, it seems straightforward to have a script that will create the six options for symbology, but "on paper" I struggle to create the code.  Any help would be appreciated.  Many thanks, Jay

0 Kudos
4 Replies
ZachBodenner
MVP Regular Contributor

I don't have an exact code solution for you, but is it possible that your unique symbols could be something like trash/large, trash/small, recycle/large etc... and all other as multiple? I don't know if that's an acceptable solution for your application, but then you might be able to get that example code to work by leaving the else portion of the statement to capture the choice-multiple questions that do in fact have multiple choices selected?

0 Kudos
JayHodny
Regular Contributor

Zach, Thanks for the idea.  If I understand you correctly, any 'cart_type multiple answers' of any two or all three cart types get returned as 'other,' which I can then manage (click off) in the symbology pane?  I will give it a try.  Thank you, Jay

0 Kudos
ZachBodenner
MVP Regular Contributor

I think that's what should happen but I'd very curious to see if that works in practice. Update when you can!

0 Kudos
JohannesLindner
MVP Frequent Contributor

You can do something like this:

var types = Split($feature.TextField1, ",")
if(Count(types) > 1) { return `multiple, ${$feature.TextField2}` }
return `${types[0]}, ${$feature.TextField2}`

 

This will return "multiple, size" when there are multiple cart types present. Alternatives:

  • delete line 2, now it will return the first cart type for carts with multiple types
  • use return "multiple" in line 2, now you have a single entry that you can switch off in the legend

Have a great day!
Johannes
0 Kudos