Onload Client Script to contain hyperlink "click here" for the URL - field is of type URL

Sachin Gavhane
Giga Guru

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

function onLoad() {


    var parentSysId = g_form.getValue('abc');


    if (parentSysId) {
        // Dynamically get the instance URL using document.location
        var instanceUrl = 'https://xyz.service-now.com/';

        var targetTable = 'https://xyz.service-now.com/x_mghmi_sw_mgmt_swm_req.do?sys_id=' + parentSysId + '&sysparm_view=';

        //var hyperlink = '<a href="' + targetTable + '" target="_blank">click here</a>';


        g_form.setValue('materiality_information', targetTable);
        //}
    }
requirement is: 
href is not working in client script, also how to make above link dynamic as per ServiceNow instance?

}
6 REPLIES 6

I am working on custom table in scoped application . there is no field with richtextlabel here

@Sachin Gavhane 

I thought it's a catalog item variable. Rich Text Label is a catalog variable type not a table field.

For a table field you can use HTML type field and use below example onLoad client script

g_form.setValue('u_test_html', '<a href="https://www.servicenow.com">ServiceNow</a>');
g_form.setReadOnly('u_test_html', true);

This is how it looks :

SumanthDosapati_0-1753453851809.png

 

Accept the solution and mark as helpful if it does, to benefit future readers.
Regards,
Sumanth