Select to view content in your preferred language

Arcade syntax - When() and &&

469
2
Jump to solution
06-26-2022 08:53 PM
Lindsay
Occasional Contributor

Hi there, Not sure the best place to post this. Just need a fresh set of eyes. Still new to Arcade and want to get a calculated expression going in my form in MapViewer.

Have I set this up right? I'm not getting an output.

var A = $feature.A
var B = $feature["B_B"]

var PA_EF = When(
A=='010417192124' && B == 'Pre2000s', 2.3, 22222)

return PA_EF

The first set of numbers there is a concatenated string. That's why I've put ''.

Also, this ultimately outputs into a double field. The default answer (22222), does that have to be a number or can I put 'No value'?

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
JohannesLindner
MVP Frequent Contributor

JohannesLindner_0-1656307083200.png

 

The When() function is set up correctly. If you don't get output, try these:

  • Make sure you actually included the expression in your form
  • Make sure your field names are correct and that you use the actual names, not the aliases
  • try using 22222.0 (a double) as default value
  • try the written-out version of When():
var A = $feature.A
var B = $feature["B_B"]

if(A=='010417192124' && B == 'Pre2000s') {
    return 2.3
}
return 22222

 

does that have to be a number or can I put 'No value'?

It has to be a number. So either a default value like your 22222 (or the more common 99999) or you could return null, which leaves the field empty.


Have a great day!
Johannes

View solution in original post

2 Replies
JohannesLindner
MVP Frequent Contributor

JohannesLindner_0-1656307083200.png

 

The When() function is set up correctly. If you don't get output, try these:

  • Make sure you actually included the expression in your form
  • Make sure your field names are correct and that you use the actual names, not the aliases
  • try using 22222.0 (a double) as default value
  • try the written-out version of When():
var A = $feature.A
var B = $feature["B_B"]

if(A=='010417192124' && B == 'Pre2000s') {
    return 2.3
}
return 22222

 

does that have to be a number or can I put 'No value'?

It has to be a number. So either a default value like your 22222 (or the more common 99999) or you could return null, which leaves the field empty.


Have a great day!
Johannes
Lindsay
Occasional Contributor

Thanks @JohannesLindner . This was really helpful. I think I've been having issues because Map Viewer is slow/not always implementing the expression at the moment due to the upgrade and what I shared was a simplified/shorter version.

0 Kudos