Arcade When Function Execution Error

715
7
08-25-2021 08:37 AM
Labels (1)
jfiacco
New Contributor II

Hi,

I'm working on a Pop-Up configuration using an Arcade expression to display related fields based on attributes in another field. I'm trying to use a When expression that states, when the well location field equals a particular string, display related fields, otherwise display nothing. There are multiple related fields associated with one well location.

I keep getting the following error: 

jfiacco_0-1629904910028.png

I've tried various versions of my expression to get rid of the error but nothing seems to be working. Here are examples of what I have tried so far:

 

When(($feature.wellLocation == 'A3'), ($feature.A3ArapCycles) && (TextFormatting.NewLine) && ($feature.A3ArapFlow), None )

When(($feature.wellLocation == 'A3'), ($feature.A3ArapCycles && TextFormatting.NewLine && $feature.A3ArapFlow), None )

When(($feature.wellLocation == "A3"), ($feature.A3ArapCycles && TextFormatting.NewLine && $feature.A3ArapFlow), None )

When(($feature.wellLocation == "A3"), ($feature.A3ArapCycles || TextFormatting.NewLine || $feature.A3ArapFlow), None )

 

Could someone take a look and let me know if anything stands out? I've looked at a lot of documentation but can't seem to figure out why I'm getting this error. I'm relatively new to Arcade so any information/ideas would be greatly appreciated.

Thanks!!

Jenna

0 Kudos
7 Replies
KenBuja
MVP Honored Contributor

To concatenate values, use "+"

When($feature.wellLocation == 'A3', $feature.A3ArapCycles + TextFormatting.NewLine + $feature.A3ArapFlow, 'None' )

0 Kudos
jfiacco
New Contributor II

Thanks, Ken. 

That removed the error but it's still not recognizing the well location value so nothing is populated in the pop-up. 

0 Kudos
KenBuja
MVP Honored Contributor

What are the possible values?

0 Kudos
jfiacco
New Contributor II

Here is a screenshot of the some of the attributes. I have over 700 fields. Each field has a prefix, in my form, indicating the specific well location. I only want to show the relevant fields for each well. So, for this well, I only want to show the attributes within the red box. I'm trying to figure out the correct expression/combination of expressions to parse down the attribute list based on the well location. Do you know of a LIKE statement or something similar that might work better than WHEN for this case?

jfiacco_0-1629910109354.png

 

0 Kudos
KenBuja
MVP Honored Contributor

You can use this type of syntax to get fields that have multiple prefixes

var test = "LAST";
return $feature[test + 'EDITOR']

 This is using one of the profiles in the Arcade playground

arcade1.png

0 Kudos
KenBuja
MVP Honored Contributor

What you could do is something like this

var array = ['ArapCycles', 'ArapFlow'];
var output;
for (var i in array) {
output += $feature[$feature.wellLocation + array[i]] + TextFormatting.NewLine;
}
return output;

This is how it works in the Playground

arcade1.png

 

  

0 Kudos
jfiacco
New Contributor II

Thanks Ken!

I ended up doing something similar. Instead of creating an array, I created a variable for each field associated with the various well houses and called them that way. It produced an output more along the lines of what I was looking for.

Example: 

var RegencyArapFlow = $feature.RegencyArapFlow
var RegencyArapMeter = $feature.RegencyArapMeter
var RegencyArapLevel = $feature.RegencyArapLevel
var RegencyArapCycles = $feature.RegencyArapCycles
var RegencyButterfieldTankLevel = $feature.RegencyButterfieldTankLevel
var RegencyBradburyTankLevel = $feature.RegencyBradburyTankLevel
var RegencySysPressure = $feature.RegencySysPressure

var varRegency;
if ((!IsEmpty(RegencyArapFlow)) || (!IsEmpty(RegencyArapMeter)) || (!IsEmpty(RegencyArapLevel)) || (!IsEmpty(RegencyArapCycles)) || (!IsEmpty(RegencyButterfieldTankLevel)) || (!IsEmpty(RegencyBradburyTankLevel)) || (!IsEmpty(RegencySysPressure))){
varRegency += TextFormatting.NewLine +
"Arapahoe Flow: " + RegencyArapFlow + TextFormatting.NewLine +
"Arapahoe Totalizer: " + RegencyArapMeter + TextFormatting.NewLine +
"Arapahoe Level: " + RegencyArapLevel + TextFormatting.NewLine +
"Arapahoe Cycles: " + RegencyArapCycles + TextFormatting.NewLine +
"Butterfield Tank Level: " + RegencyButterfieldTankLevel + TextFormatting.NewLine +
"Bradbury Tank Level: " + RegencyBradburyTankLevel + TextFormatting.NewLine +
"System Pressure: " + RegencySysPressure + TextFormatting.NewLine
}
return varRegency

 

Thanks again for your help!

0 Kudos