- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2022 11:49 AM
I have a client requirement to add a URL field type in catalog variables. This URL field has link to Knowledge Articles ( it changes when other field 'Job role' changes). There is an onChange Script that works to pull up the KA link( currently saved in a table with value like: /kb_view.do?sysparm_article=KB0010001)
Initially, we used part of URL so that it dynamically change when instance is different (eg: /kb_view.do?sysparm_article=KB0010001). But URL field type throws Error in RITM, SCTASK page -' invalid URL'
I assume, URL field need full URL, with instance name.
is there a way we can store the Knowledge article number and then prepend the entire active url before that.
example: https://[instance name].service-now.com/kb_view.do?sysparm_article=KB0010001
Solved! Go to Solution.
- Labels:
-
Service Catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2022 11:22 PM
Hi Shruti,
I was thinking about some easier solution.
Would it make sense to run a script (either background or better a fix script) to actually change the link in the table with KB links from relative link to a full link with your instance prefix? In that case we would not have to touch the existing logic at all.
Something like that.
var instanceURL = gs.getProperty('glide.servlet.uri');
// need to shorter the URL by last character as it already ends with backslash, e.g. https://dev1234.service-now.com/
var instanceShort = instanceURL.slice(0,instanceURL.length - 1);
var roleMappingGR = new GlideRecord('u_job_role_mapping');
// we only want records with NOT EMPTY KB article URL and not those that start with http
var grQuery = 'u_knowledge_article_url!=NULL^u_knowledge_article_urlNOT LIKEhttp';
roleMappingGR.setLimit(1);
roleMappingGR.addEncodedQuery(grQuery);
roleMappingGR.query();
while (roleMappingGR.next()) {
var originalLink = roleMappingGR.getValue('u_knowledge_article_url');
var newLink = instanceShort + originalLink;
roleMappingGR.u_knowledge_article_url = newLink;
roleMappingGR.update();
}
You can test this script as it contains setLimit to 1, if all seems ok you may increase the limit or remove it completely.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2022 01:33 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2022 01:38 PM
it is URL type
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2022 01:40 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2022 01:43 PM
Ok I got it, it seems I might have messed around with this in the past already 🙂
Well, if you are getting the KB number from another table (I guess by AJAX call), you can construct the first part of URL by simply reading the glide.servlet.uri property (don't be confused if you don't find it in the properties list, but it works).