Onload Client Script to contain hyperlink "click here" for the URL - field is of type URL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2025 08:52 AM
Hi Team,
I need "click here" hyper link for the field of type URL
in the below script--materiality_information is the field of type url
requirement is:
href is not working in client script, also how to make above link dynamic as per ServiceNow instance?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2025 09:09 AM
Hi @Sachin Gavhane ,
try this set the isolate script value to false
script
function onLoad() {
var parentSysId = g_form.getValue('abc');
if (parentSysId) {
// Dynamically get the instance URL using document.location
var instanceUrl = location.origin;
var targetTable = instanceUrl + '/x_mghmi_sw_mgmt_swm_req.do?sys_id=' + parentSysId + '&sysparm_view=';
var hyperlink = '<a href="' + targetTable + '" target="_blank">click here</a>';
g_form.addInfoMessage(hyperlink);
g_form.setValue('materiality_information', targetTable);
}
}
if this doesn't work
also check if the parentsysid is valid and put an alert inside if condition and check if it's getting inside the if block
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2025 12:17 PM - edited 07-22-2025 12:21 PM
@Chaitanya ILCR
here "addinfomessage" shows correct hyperlink - with "click here"
but i want that click here for the field "materiality_information".
g_form.setValue('materiality_information', targetTable);
here setvalue is showing full url
materiality information field is of type url
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-23-2025 11:05 PM
Hi @Sachin Gavhane ,
you didn't attach the screenshot
it shouldn't show full url? what's your expectation?
please share these things in details with some screenshots
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2025 09:15 AM
Use 'Rich Text Label' type of variable instead of URL type and use below sample script.
g_form.setLabelOf('test_url', '<a title="ServiceNow" href="www.servicenow.com" rel="nofollow">Click Here</a>');
Accept the solution and mark as helpful if it does, to benefit future readers.
Regards,
Sumanth