Select to view content in your preferred language

Attribute Expression for popup not working.

932
6
Jump to solution
01-03-2024 02:52 PM
Labels (1)
sanderson_OC
New Contributor II

Hi, I am struggling with Arcade Expressions! I have a web map in agol that I am trying to customize the popup. I want to display different text based on the project status.

So if the Current Phase = Construction,

I want to display a sentence like "Project started in the {PROJ_BEGIN} of {BEGIN_YEAR} and is expected to be completed in the {PROJ_END} of {END_YEAR} "

my attribute expression

var status = $feature.CURR_PHASE
var phrase = When (status == 'Construction'"construction sentence here"status == 'Design'"design sentence here"status == 'Completed'"completed sentence here""N/A")
return phrase;
 
My popup is only displays N/A, it's not reading the value, obviously I am missing something??
 
sanderson_OC_0-1704322213278.png

 

Any suggests would be greatly appreciated!

0 Kudos
2 Solutions

Accepted Solutions
KenBuja
MVP Esteemed Contributor

Having them in a domain makes a difference. You just have to make one change

var status = DomainName($feature, 'CURR_PHASE')

View solution in original post

sanderson_OC
New Contributor II

Oh thank you so much! It worked when I added that line. I am eternally grateful 🙂

View solution in original post

0 Kudos
6 Replies
KenBuja
MVP Esteemed Contributor

That expression should work. What are the values in the field "CURR_PHASE"? You can see what is getting returned by adding in the console function in line 2.

var status = $feature.CURR_PHASE;
console($feature.CURR_PHASE)
var phrase = When (status == 'Construction', "construction sentence here",
                   status == 'Design', "design sentence here", 
                   status == 'Completed', "completed sentence here", 
                   "N/A")
return phrase;

In the popup expression window, click Run, then click the Console tab to see the results

console1.png

0 Kudos
sanderson_OC
New Contributor II

Hi...added the console function and it returns N/A? The values for CURR_PHASE are in a domain called CIP_CURRENT_PHASE

sanderson_OC_0-1704383235407.png

 

0 Kudos
sanderson_OC
New Contributor II

Here is the information on that field...doesn't seem to be any issues there? Thank you so much for the help I have been driving myself crazy trying to get something to work!

sanderson_OC_1-1704383462165.png

Any ideas or maybe another work around? Because those values are in a domain do I need for reference them a different way?

 

 

0 Kudos
sanderson_OC
New Contributor II

Oops sorry, I forgot to click on the console tab! It is showing Closeout. So I updated to add all the values. But still showing N/A in popup?

var status = $feature.CURR_PHASE;
console($feature.CURR_PHASE)
var phrase = When (status == 'Construction', "construction sentence here",
                   status == 'Design', "design sentence here",
                   status == 'Completed', "completed sentence here",
                   status == 'Closeout', "completed project",
                   status == 'Study', "only looking for now",
                   "N/A")
return phrase;
 
 
0 Kudos
KenBuja
MVP Esteemed Contributor

Having them in a domain makes a difference. You just have to make one change

var status = DomainName($feature, 'CURR_PHASE')
sanderson_OC
New Contributor II

Oh thank you so much! It worked when I added that line. I am eternally grateful 🙂

0 Kudos