How to set URL within javascript

Kifrez
Kilo Guru

Hi,

I have a URL type field and I would like to set knowledge base article.

For example, I would like to show as per following KB012345
find_real_file.png

How do I achieve this using javascript within Workflow?

I have the following script

var instance = gs.getProperty('glide.servlet.uri');
var kbnumber = 'KB001234';
var kburl = instance + "kb_view.do?sysparm_article=" + kbnumber;

<a href="kburl" target="_blank">KB001234</a>
10 REPLIES 10

Alberto Consonn
ServiceNow Employee
ServiceNow Employee

Hi @Freddy 

check the solution here, it should work:

https://community.servicenow.com/community?id=community_question&s

If I have answered your question, please mark my response as correct and helpful so that others with the same question in the future can find it quickly and that it gets removed from the unanswered list.

Thank you very much

Cheers
Alberto

Hi Alberto, thanks for the link. however it doesn't work. Possibly due to URL field type.

This is my script

var instance = gs.getProperty('glide.servlet.uri');
var kbnumber = 'KB0011609';
var kburl = instance + "kb_view.do?sysparm_article=" + kbnumber;
var setkblink = '[code]<a href="' + kburl + '" target="_blank">' + kbnumber + '</a>[code]';

g_form.setValue('u_kbarticle', 'setkblink', 'kbnumber');

Hi,

you can insert HTML content in work notes using [code] but not in URL field

Regards
Ankur

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

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

So you want to update the URL field from workflow script

URL field can only hold url

please explain in detail what exactly is required

Regards
Ankur

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