Display a hyperlink on the label for a checkbox
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2018 10:26 AM
I have requirement to display a hyperlink embedded into the text for checkbox type variable that is defined on a catalog item. I was able to get the link to show using an onLoad script as follows:
function onLoad() {
$$('label').each(function(i){
if (i.innerHTML.indexOf('Honorarium') >-1) {
var text = "<a href='http://www.google.com'>"+"Link"+"</a>";
i.innerHTML = "Honorarium " + text;
}
});
}
and the link shows as below:
But when I click on the hyperlink, it does not take to the website. What am I doing wrong?
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2018 12:52 PM
When I tried this in my PDI, I found the following error in the console:
Mixed Content: The page at 'https://[...].service-now.com/nav_to.do?uri=%2Fcom.glideapp.servicecatalog_cat_item_view.do%3Fv%3D1%26sysparm_id%3D04b7e94b4f7b4200086eeed18110c7fd' was loaded over HTTPS, but requested an insecure resource 'http://www.google.com/'. This request has been blocked; the content must be served over HTTPS.
Add target='_blank' in the <a> tag and it will work:
function onLoad() { $$('label').each(function(i){ if (i.innerHTML.indexOf('Honorarium') >-1) { var text = "<a href='http://www.google.com' target='_blank'>"+"Link"+"</a>"; i.innerHTML = "Honorarium " + text; } }); }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2019 12:10 PM
This works in UI16, but not in Service Portal. Currently running London, Patch 3
Do you have a solution for Service Portal?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2018 03:25 PM
Hi,
Did you ever get this to work? I seem to have similar request & running into issues. Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2019 12:55 PM
Hi,
This won't work on the service portal (at least for Kingston and London). To get any form of html/link and all that to show you have to create a widget Service Portal > Service Portal Configuration (in back-end navigation), add your html to the html section of that widget (i.e. <a href="http://www.google.com">Click here for Google</a>), then create a macro variable on the form (catalog item or otherwise) and on the "Default Value" tab of that variable, pick the widget for the widget field:
This won't show right next to the checkbox (like as it's own label), but does allow for HTML/LINK to be placed near it if this and the checkbox are next to each other via sequence order.
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!