Select to view content in your preferred language

Square brackets are being inserted into an arcade expression

659
1
Jump to solution
10-17-2023 11:57 AM
Labels (1)
ccowin_odfw
Frequent Contributor

Hello,

So I have a table with URL links if a specific boundary has a PDF map available for folks to download. I created an arcade expression to add the HTML link. Not all boundaries have a URL so needed some logic to return nothing if there is no URL. However, there are two square brackets that are showing up and I have no idea why.

The pop-up:

ccowin_odfw_0-1697568876986.png

The code:

if ($feature.CLOSURE_MAP != ''){

  if ($feature.Map_URL != '') {

    var urls = Split($feature.Map_URL, ', ')
    var links = []
    for (var i in urls) {
      var url = urls[i]
      links += Concatenate(["<a href=", url, ">View Map</a>"])
      links += ""
    }
    return {
      type : 'text',
      text : links
    }
  }
}
0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

You are instantiating links as an array (line 6) but are using it as a string. Try this

    if ($feature.CLOSURE_MAP != ''){

      if ($feature.Map_URL != '') {

        var urls = Split($feature.Map_URL, ', ')
        var links;
        for (var i in urls) {
          var url = urls[i]
          links += Concatenate(["<a href=", url, ">View Map</a>"])
          links += ""
        }
        return {
          type : 'text',
          text : links
        }
      }
    }

 

View solution in original post

1 Reply
KenBuja
MVP Esteemed Contributor

You are instantiating links as an array (line 6) but are using it as a string. Try this

    if ($feature.CLOSURE_MAP != ''){

      if ($feature.Map_URL != '') {

        var urls = Split($feature.Map_URL, ', ')
        var links;
        for (var i in urls) {
          var url = urls[i]
          links += Concatenate(["<a href=", url, ">View Map</a>"])
          links += ""
        }
        return {
          type : 'text',
          text : links
        }
      }
    }