Select to view content in your preferred language

Arcade expression keeps running without calculating anything in Portal web map

374
4
10-17-2023 12:09 PM
AlcoGISUser
New Contributor III

Needed to add a field to a published layer and calculate values based on existing field. Tried using "When" function but the expression has remained in "Calculating" mode for over 30 minutes (only 174 records). Can someone tell me if my syntax is off?

 

var target = $feature["dept_name"]

var source = $feature["user_business_unit"]

target = When(
source == 'ACOFD',
'Fire',
source == 'ALCSO',
'Sheriff',
source == 'ASESR',
'Assessor',
source == 'AUDTR',
'Auditor',
source == 'BOARD',
'BOS',
source == 'CAOFF',
'CAO',
source == 'CMDEV',
'CDA',
source == 'COLIB',
'Library',
source == 'CONSL',
'Counsel',
source == 'DAOFF',
'DA',
source == 'GENSA',
'GSA',
source == 'HDSVS',
'Health Department',
source == 'HRSVC',
'Human Resources',
source == 'ITDPT',
'ITD',
source == 'OFFCS',
'Child Services',
source == 'PBWKS',
'PWA',
source == 'PDOFF',
'Public Defender',
source == 'PROBT',
'Probation',
source == 'ROVTR',
'ROV',
source == 'SOCSA',
'Social Services',
source == 'TRETC',
'Tax Collector',
source == 'ZONE7',
'Zone 7', source)

Tags (1)
0 Kudos
4 Replies
KenBuja
MVP Esteemed Contributor

Your code should look like this, removing the target variable:

var source = $feature["user_business_unit"]

When(
  source == 'ACOFD', 'Fire',
  source == 'ALCSO', 'Sheriff',
  ...
  source == 'ZONE7', 'Zone 7',
  source)

 

0 Kudos
AlcoGISUser
New Contributor III

Ah, I see. I don't need to declare target field because I am already selecting it via "calculate" when clicking the header. Thanks!

0 Kudos
AlcoGISUser
New Contributor III

I spoke to soon. Changed it to this and getting same behavior:

 

var source = $feature["user_business_unit"]

When(
source == 'ACOFD',
'Fire',
source == 'ALCSO',
'Sheriff',
source == 'ASESR',
'Assessor',
source == 'AUDTR',
'Auditor',
source == 'BOARD',
'BOS',
source == 'CAOFF',
'CAO',
source == 'CMDEV',
'CDA',
source == 'COLIB',
'Library',
source == 'CONSL',
'Counsel',
source == 'DAOFF',
'DA',
source == 'GENSA',
'GSA',
source == 'HDSVS',
'Health Department',
source == 'HRSVC',
'Human Resources',
source == 'ITDPT',
'ITD',
source == 'OFFCS',
'Child Services',
source == 'PBWKS',
'PWA',
source == 'PDOFF',
'Public Defender',
source == 'PROBT',
'Probation',
source == 'ROVTR',
'ROV',
source == 'SOCSA',
'Social Services',
source == 'TRETC',
'Tax Collector',
source == 'ZONE7',
'Zone 7', source)

 

0 Kudos
KenBuja
MVP Esteemed Contributor

I used the same syntax to test on a sample dataset and it worked as expected. Can you edit individual records?

0 Kudos