Select to view content in your preferred language

Popup FieldsContent - using arcade to return url value for an attribute

850
4
06-20-2022 02:01 AM
MichailMarinakis1
Frequent Contributor

Hi all, 

we are using a popup for one of our features with a FieldsContent. 

We are using an arcade expression for one of the fields. The expression returns a url calculated with a concatenated string. 

It was a positive surprise that the API understands that it is a hyperlink and it creates an anchor element with the text "View" at the popup. The users can click on the anchor element and a new tab opens with the link. 

We have a new request from our customer to change the text "View" on the hyperlink to whatever we want. 

Is this possible?

We tried to use arcade to return an anchor element correctly structured but with no luck. 

Any ideas are welcome! 

0 Kudos
4 Replies
ReneRubalcava
Honored Contributor

Here's an Esri blog post that shows how you can do exactly that! Arcade is amazing, ha.

https://www.esri.com/arcgis-blog/products/arcgis-online/mapping/part-1-introducing-arcade-pop-up-con...

0 Kudos
MichailMarinakis1
Frequent Contributor

Hi Rene, 

thanks for the fast reply! I could not find an answer to neither part 1 (nor part 2) of the blog post above (nice read though 😉 ). 

In our case, we have a popup with a fieldContent shown for a feature. The arcade expression for one of the fields is something like that:

 

return 'https://test.com/' + $feature.ID

 

The result on the popup looks like that: 

MichailMarinakis1_0-1655815848398.png

After inspecting the element, the value of this field is, magically, an anchor element with href the concatenated link above, and the word "View" as text. It's a welcome behavior actually!

Our question is:

Is there anyway to change the default value "View" somehow?

Could we return an anchor element as the value of a field ? 

 

0 Kudos
ReneRubalcava
Honored Contributor

Can you change the expression to something like this?

var myUrl = 'https://test.com/' + $feature.ID
return `<a href="${myUrl}">Click to learn more.</a>`
0 Kudos
MichailMarinakis1
Frequent Contributor

yeap, we did that: 

MichailMarinakis1_0-1655883378029.png

I can see a workaround, create a custom content that returns a table element (or returns a widget) with the proper structure for the whole FieldsContent. It's kind of an overkill, just for one attribute to generate a custom popup content. If there is no other way, we might go for that but I think it should be feasible with arcade somehow!

0 Kudos