Arcade for Webmap - When Function Weirdness

405
3
Jump to solution
09-06-2022 03:17 AM
Labels (2)
LiamHarrington-Missin
Occasional Contributor II

Hi all, 

I've got stuck and I can't work out why.  My workflow is as follows - a user in the field captures some data and I want to use Arcade to classify that data to create improved visuals.  I've written a When statement which appears to be working in the sandpit but once it goes to the map, the value fails to materialise....

LiamHarringtonMissin_1-1662459123553.png appears to work, but...LiamHarringtonMissin_2-1662459407399.png

Nothing appears in the popup?  I should be getting a VL at the very least.

// Calculate the width category
var width_cat = when(
    $feature.WIDTH<=0.5,'VN',
    $feature.WIDTH<=1,'N',
    $feature.WIDTH<=2,'M',
    'W')

// Extract Oil Distribution to make following coding easier
var oilDist = $feature["OIL_DIST"]

// Calculate the Initial Ranking
var ranking = when(
    oilDist=='SP'&&width=='M','L',
    oilDist=='SP'&&width=='W','L',
    oilDist=='PT'&&width=='N','L',
    oilDist=='PT'&&width=='M','M',
    oilDist=='PT'&&width=='W','M',
    oilDist=='BR'&&width=='VN','L',
    oilDist=='BR'&&width=='N','M',
    oilDist=='BR'&&width=='W','H',
    oilDist=='CN'&&width=='VN','L',
    oilDist=='CN'&&width=='N','M',
    oilDist=='CN'&&width=='M','H',
    oilDist=='CN'&&width=='W','H',
    'VL')

Console('Width',$feature.WIDTH,'width_cat: ', width_cat,'oilDist: ', oilDist)
return ranking

 

Anyone any ideas?  Do you get the same?

 

Liam
0 Kudos
1 Solution

Accepted Solutions
JohannesLindner
MVP Frequent Contributor

Your variable is named width_cat, but you're using width in the When() function.


Have a great day!
Johannes

View solution in original post

3 Replies
JohannesLindner
MVP Frequent Contributor

Your variable is named width_cat, but you're using width in the When() function.


Have a great day!
Johannes
LiamHarrington-Missin
Occasional Contributor II

Well now I feel stupid... Thanks @JohannesLindner 

Liam
0 Kudos
JohannesLindner
MVP Frequent Contributor

Ha, that's no reason to feel stupid! I've misnamed or misspelled variables so often that it's one of the first things I look for, now...


Have a great day!
Johannes
0 Kudos