So a question was asked way back in 2012 about adding hyperlinks in error messaging. 12 years have passed, ArcPro is the main desktop application and this has not come to pass so I'm asking now if this can be considered as an idea.
Currently my error messaging might be something like this:
arcpy.AddError("Some error, you need to go to Amazon!")
What I would like to be able to do is something like this, but this simply prints everything:
arcpy.AddError('Some error, you need to go to <a href="https://www.amazon.co.uk">Amazon!</a>')
In my use case scenario I would replace the URL with a URL to an error page for an online manual.
Hi @DuncanHornby,
There is an existing pathway for this that you might be interested in.
Internally, we do have some additional message features that were created for a subset of Pro teams that develop geoprocessing tools. Supporting links was part of that. It's organized as a json type of structure (like below) that you can use with the arcpy message functions.
Currently, it's not officially supported, and there is potential for this to change in the future.
msg = """json:
[{"element": "content",
"data": ["This is my link: ",
{"element": "hyperlink",
"data": "Esri",
"link": "https://www.esri.com/"}]}]"""
arcpy.AddMessage(msg)
Hope this helps,
-Dave
Dave,
This is great news but I feel cautious to use it as you say its "not officially supported", which to me could indicate that it could be removed without warning as well as becoming official.
Now this is just me but I find using json horrible, it's just all brackets within brackets with colons upon colons to me! I have always found json hard to decypher. So if the Pro team were to consider to make this a supported feature (which would be great!) then I ask them to consider an easier approach like a <a></a> or maybe some sort of object based approach? For example a geoprocessing tool returns a result object which one can tap into the various properties. May be the AddMessage can take of a sort of message object? Just an idea.
Anyway this I think would be really useful and surprised that it's not in the documentation, so at the minimum you could suggest to the team to expand the help documentation to show off this very useful property.
Thanks!
Duncan
Hi DavidWynne,
I have a geojson file present in my local computer path i.e., c:/esrifolder/sample.geojson, how to change the bellow msg params to open the file from local(my computer)
msg = """json: [{"element": "content", "data": ["This is my link: ", {"element": "hyperlink", "data": "Esri", "link": "https://www.esri.com/"}]}]"""
I have change the "link" key to href, file:/// etc., but did not worked for me. Do we have any ESRI document reference related to this ?
Kindly suggest,
From @PeterKonrad in arcpy geoprocessing details clickable hyperlink:
[I want to] add a clickable hyperlink to the details of a custom python geoprocessing tool in ArcGIS Pro…I would like the end user to have the option to open the output pdf file from the results window.
![]()
I think I remember one of the Error reporting functions resulting in a clickable link, which would imply the basic functionality is there in the underlying structure.
It's also worth noting, though, that unlike Desktop, the details don't show up automatically, and I know many who never even glance at them, which severely altered how I write my scripts and what sort of debug/feedback I write.
If you do want this end result, a near-term workaround might be a Boolean checkbox for whether to open the file when done. If they check the box, you call the relevant Python function to open the file in the native system viewer; I haven't used it in forever, but a quick Google suggests the command might've been os.startfile, though you'll want to check me on that.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.