How to convert values in a string field to clickable link?

Kevin Smith2
Giga Expert

Hi,

We have a string field (description) on certain conditions, we are populating the description field with clickable LINK via BR.

The link is getting populated in plain text.

How can we make the text clickable?

Here is my script:

(function executeRule(current, previous /*null when async*/ ) {

    var deepLinkGenerator = new global.MobileDeepLinkGenerator("agent");
    var link = deepLinkGenerator.getFormScreenLink("472ceb7253b0330097a2ddeeff7b12f6", current.getTableName(), current.getValue("sys_id"));
    current.setValue('description', link);
    current.update();

})(current, previous);

Thanks

Kevin

1 ACCEPTED SOLUTION

Hi,

I am not sure on those 2 functions you are using from script include

but you can try this and check if it works and then debug the function

var url = '<a href="' + gs.getProperty('glide.servlet.uri') + '/nav_to.do?uri=' + current.getTableName() + '.do?sys_id=' + current.sys_id + '">' + current.getDisplayValue() + '</a>';

current.work_notes = '[code]' + url + '[/code]';

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

14 REPLIES 14

RaghavSh
Kilo Patron

You can change the string type field to URL or HTML type field.

String and multiline text fields will show it as plain text only.


Raghav
MVP 2023

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

description is string field so it won't show the anchor tag with link

Adding clickable link only works with journal fields such as work_notes and comments.

like this for work notes

var url = '<a href="' + gs.getProperty('glide.servlet.uri') + '/nav_to.do?uri=' + current.getTableName() + '.do?sys_id=' + current.sys_id + '">' + current.getDisplayValue() + '</a>';

current.work_notes = '[code]' + url + '[/code]';

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

How can I embed this code in mine?

Hi,

you can only add clickable link to journal fields.

Your description is string field so you cannot

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader