Select to view content in your preferred language

arcade expression notworkig

124
1
02-12-2025 01:33 PM
anonymous55
Frequent Contributor

Hello,

I have this code for a popup, and part of it includes an arcade expression to change the value, but my code is not working. I’m just starting to learn JavaScript right now, so I’m not very advanced in it. Thanks!

 

 

 

 

//popup for Intersection
  const IntersectionPopupTemplate = {
    // You can dynamically set the title, e.g., the block's name
    title: "Holiday Embargo (Intersection)", 
    content: [
      {
        type: "fields",
        fieldInfos: [
          {
            fieldName: "OnStreetName", 
            label: "Cross Street 1"
          },
          {
            fieldName: "FromStreetName", 
            label: "Cross Street 2"
          },
          {
            fieldName: "BoroughCode", 
            label: "Borough",
            format: {
              expression: `
                var borough = $feature['BoroughCode'];
                return (borough == "M") ? 'Manhattan' :
                       (borough == "X") ? 'Bronx' :
                       (borough == "B") ? 'Brooklyn' :
                       (borough == "Q") ? 'Queens' :
                       (borough == "S") ? 'Staten Island' : 'n/a';
              `
            }
          }
        ]
      }
    ]
  };

 

 

 

 

Tags (1)
0 Kudos
1 Reply
KenBuja
MVP Esteemed Contributor

Use the When function instead of the ternary operator

var borough = $feature['BoroughCode'];
When(borough == "M", 'Manhattan',
     borough == "X", 'Bronx',
     borough == "B", 'Brooklyn',
     borough == "Q", 'Queens',
     borough == "S", 'Staten Island',
     'n/a')