Hi,
I am looking at using arcade to create a hyperlink in a popup based on attributes held within the data.
I have created an attribute expression as follows:
IIf($feature["TELEMETRY_MATCH"]=='YES', 'url'+$feature.FULLNAME+'?anotherpieceoftext', 'Currently not linked to telemetry')
I want to continue to use the A list of field attributes option, with the output of this expression:
I have successfully done this but instead of just a string i want the result when 'YES' to be a hyperlink.
Basically i want this to be a hyperlink:
Is this possible? Any help greatly appreciated.
Thanks
Ciaran
Hi Ciaran Higgins ,
When you return a string that represents a valid url it should be displayed as a link. I notice that you return this:
'url'+$feature.FULLNAME+'?anotherpieceoftext'
Starting the url with a text "url" will not result in a valid url. What is the exact url you try to create?
Hi Xander Bakker,
The url starts http://telemweb/graph/
Then it contains the full name contained in the table, then finishes with ?Historic&applet
How do i return it as a link? I made an attempt at using href= but i was unsuccessful. I was able to do it as a link when an image is included as media but this isn't a tidy solution when there is no valid link. Using the iif helped in these cases
Hi Ciaran Higgins ,
You are correct to use the iif in order to return a string. The pop-up will interpret it as simple text or when it is a valid URL it will present the link with a text like "more information" that is clickable. Is it possible to share a valid example of a URL that will be return?
Hi Xander Bakker
You got me thinking the full name has spaces in it and that might be why this is not working, when the link is copied to an internet browser the spaces are automatically filled with %.
After figuring this out I tried the following:
var removespaces = Replace($feature.FULLNAME, ' ', '%')
var link = 'http://telemweb/graph/' + removespaces +'?Historic&applet'
IIf($feature["TELEMETRY_MATCH"]=='YES', link , 'Currently not linked to telemetry')
However it does not return the correct output, it now just says no information available, is this % a special character, if I use ? the popup displays, although not the correct url:
Example of full name :
NWA1A BTCC C Diamond.Coolagh Road LM.Points.Coolagh Bolie Flow
Example of full correct url:
Hi Ciaran Higgins ,
I'm glad it works now. Just to be on the safe side, it would be better not to use Replace, but to use the UrlEncode Arcade function. This will make all characters valid for use in a URL.
To use your example text:
UrlEncode("NWA1A BTCC C Diamond.Coolagh Road LM.Points.Coolagh Bolie Flow")
Returns:
NWA1A%20BTCC%20C%20Diamond.Coolagh%20Road%20LM.Points.Coolagh%20Bolie%20Flow
So just use this:
var link = 'http://telemweb/graph/' + UrlEncode($feature.FULLNAME) +'?Historic&applet'
Hi Xander Bakker
I tried to use the UrlEncode but get Execution Error:Runtime Error: Function Not Found: UrlEncode.
Looking into the function it is only available from version 1.7 but i am trying to do this in our Portal which is 10.6.1 unfortunately
Hi Ciaran Higgins ,
I see... You are using portal, right? What version of Enterprise do you have?
UrlEncode was introduced in Arcade version 1.7 which means that you need Enterprise / portal 10.7.1 to use it.
Both enterprise and portal are 10.6.1
Thanks for all your help it has been very useful and informative!