Basic arcade help - Merging fields in symbology

01-18-2022 07:20 PM
Occasional Contributor II

I'm getting into Arcade this week and have a few questions. I'm reading up on Arcade articles and learning a lot, but I'm still not sure how to apply this to my situation. These questions should be easy wins for those already versed in Arcade.

1. How do I merge the below symbology for Complete into 1?



CodeDesired text output
Desired fill colour @ 50% transparency
Desired outline colour. no transparency. width- 1
To doTo don/aGrey
Not able to. No contact details.Not able to. No contact details.OrangeOrange

In progress

In progressYellowYellow
Complete - DocusignCompleteGreenGreen
Complete - Pen and paperCompleteGreenGreen
Complete - S123CompleteGreenGreen
TriedTried. Can't get ahold.OrangeOrange
DoesNOTConsentDoes NOT ConsentRedRed


var ConsentFormStatusSymbology = When(
$feature.ConsentFormStatus=='To do', 'gray',
$feature.ConsentFormStatus=='Not able to. No contact details.','yellow',
$feature.ConsentFormStatus=='Pending', 'orange',
$feature.ConsentFormStatus=='Complete - Eversign', 'green',
$feature.ConsentFormStatus=='Complete - Manual', 'green',
$feature.ConsentFormStatus=='Complete - Survey123','green',
$feature.ConsentFormStatus=='Tried', 'yellow',


var color = 'white';

if ($datapoint.ConsentFormStatus == 'To do'){
            color = '#d9d9d9';
if ($datapoint.ConsentFormStatus == 'Not able to. No contact details.')
            color = '#ffee65';
if ($datapoint.ConsentFormStatus == 'Pending.') 
            color = '#ffee65';
if ($datapoint.ConsentFormStatus == 'Complete - Eversign')
            color = '#55ff00';
if ($datapoint.ConsentFormStatus == 'Complete - Manual')
            color = '#55ff00';
if ($datapoint.ConsentFormStatus == 'Complete - Survey123')
            color = '#55ff00';
if ($datapoint.ConsentFormStatus == 'Tried')
            color = '#ffee65';
if ($datapoint.ConsentFormStatus == 'DoesNOTConsent')
            color = '#ff0000';


2. Show fields in pop-up based off of Client. There are 3 different clients. Each require different data to be collected. I only want relevant data to show in the pop-ups. I believe you can do this through the filter function. Filter is used and mentioned in this article, but it is too complex for me to be able to replicate.

function filterValidFields(fieldName){
  // skip some system fields and some other fields that are not needed
  var skipNames = [
  return !includes(skipNames, lower(fieldName)) && !IsEmpty($feature[fieldName]) && !IsNan($feature[fieldName]); 

var validFields = Filter(Map(fields, getNames), filterValidFields);
var attributes = {};
var fieldInfos = [];
var fieldMetaInfo = getFieldsMetaData();
for (var f in validFields){
  var fieldName = validFields[f];
  var fieldMeta = fieldMetaInfo[Lower(fieldName)]
  var fieldAlias = fieldMeta.alias  
  Push(fieldInfos, { fieldName: fieldAlias})
  attributes[fieldAlias] = formatField(fieldMeta)

If polygon falls under Client A, show the following fields Field1, Field2, Field3.

If polygon falls under Client B, show the following fields Field4, Field5, Field6.

Also if this isn't the right place to be posting this question, I shouldn't be posting these kinds of questions or you have any recommended resources, please let me know.

The end goal is to use this in Map Viewer, but also in the dynamic content/text widget in Experience Builder. 

Tags (2)
0 Kudos
2 Replies
MVP Frequent Contributor

Separate questions really ought to be in separate posts, as it helps keep the post and its responses more focused.

For your first question, you could just make use of some or combinations. But the, since you're not really doing anything to the status field, just checking that it equals certain things, you can use Decode instead, as it is more concise.

If you have three situations which output "green" from your expression, the symbology should group those together for you, provided that you are using the expression itself in your symbology settings, as opposed to driving the symbology off of the status field.

Expects($feature, 'ConsentFormStatus')

var cfs = $feature.ConsentFormStatus

var color = Decode(cfs,
    'To do', 'gray',
    'Not able to. No contact details.', 'yellow',
    'Pending', 'orange',
    'Complete - Eversign', 'green',
    'Complete - Manual', 'green',
    'Complete - Survey123', 'green',
    'Tried', 'yellow',
    'DoesNOTConsent', 'red',

return color


- Josh Carlson
Kendall County GIS
Occasional Contributor II

Hi @jcarlson , Thank you for your help. I'm not sure if I've followed your steps correctly, so I'm going to include some screen shots.

Current state:



In Map Viewer, if I go to Styles, +Expression and add in the code you've shared, I get this.






I can work with this because it does do the grouping I need it to, but because I am also on my arcade learning journey, I'd like to get down to the bottom of this. Sorry if this is painful for you! We've got the code to group them, but not output the colour. I've been doing some reading up about how to do this, but I think I'm getting confused about how to apply it in pop-ups for Map Viewer and how it works differently in Dashboards and Experience builder...

My follow-up questions would be, how do I control the transparency and outline colour too. Do you have any beginner level resources you recommend looking at? I appreciate all your help, but am aware this probably isn't your day job either. I have been looking on the ESRI blog for arcade articles. The ESRI arcade developer stuff is good too, but as someone who is not a natural code/developer, examples rather than explanations tend to work better for me.



0 Kudos