How do you set the markup of a Rich Text Label?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2022 02:59 PM
I have a catalog client script reading the contents of a lower Order variable and using it to append to a few URLs that should be displayed in a higher Order variable. Since rich text labels can have hyperlinks, it makes sense to use that. How do you set the markup of a rich text label in code? Right now nothing is displaying from using g_form.setValue().

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2022 04:35 PM
Hi,
.setLabelOf() will change the rich text label on ServicePortal but not in UI.
Example:
Rich Text Label definition
Client Script
function onLoad() {
g_form.setLabelOf('rich_text_label', '<a title="ServiceNow" href="www.servicenow.com" rel="nofollow">ServiceNow</a>');
}
Result in Service Portal

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2022 04:57 PM
Rich label text may be changed in UI using DOM manipulation. DOM manipulation is not highly recommended because it may break when ServiceNow is versioned up.
Just will provide sample for completeness.
Following are the steps to change Rich label text using DOM manipulation,
- Set "Isolate script" to false (unchecked).
- Get the ID of the Rich Text Label to change (usually can be found by right-clicking near the label and selecting "Inspect".
- Client script
function onLoad() { var g = gel('element.IO:6470cd6d2f6e8d509d10b2e72799b6b4'); g.innerHTML = '<a href="https://www.servicenow.com">ServiceNow</a>'; }​
Execution result:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-30-2022 08:19 AM
This didn't work, but I found out while trying it that you can put links in an info message, which achieved the same intended effect. Thanks.