modify read only script include - extend script include
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2023 01:56 AM
Best reader,
When atttaching a knowledge article to a major case, an "Additional Comment" is added. The URL is redirecting to the wrong "view". Its showing the knowlede base in the background. But this message is for customer so should be redirected to the knowledge serviceportal url.
- To achieve this behaviour I need to customize the "cxs_Knowledge" Script Include to modify the URL which is added.
- On Line 42 inside the "getArticleInfoInternal" Method you will see the following code is being used:
var queryParameter = 'kb_view.do?sys_kb_id=';
Since the script include is read onlyI need to use a Override Method. I have tried it with the documentation below, but I can't figure it out. Could someone help me with this?"
Best regards,
Mike

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2023 07:58 PM - edited 04-09-2023 02:09 PM
Hello Mike,
I was actually able to do this with a client script. I added some extra checks in it to also prevent IT only KB Articles from being attached to incidents where the caller was an end user.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
if (newValue.includes('kb_view.do')) {
g_form.getReference('caller_id', company);
}
}
function company(caller){ //Check to see if caller is part of the company (this is due to having callers that do not yet have access to our environment.
if (caller.company == '357bc3411b39d8503d4477761a4bcbaa'){
var comment = g_form.getValue('comments');
// retrieve KB link between [code] blocks
var commentLink = comment.substring(
comment.lastIndexOf('[code]') + 6,
comment.lastIndexOf('[/code]')
);
// retrieve KB number from URL
var kbNumberSub = commentLink.match(' >(.*) : ')[1];
var kbNumber = trim(kbNumberSub);
//call script include to verify if self-service kb
var ga = new GlideAjax('CheckKnowledgeBase');
ga.addParam('sysparm_name', 'isSelfService');
ga.addParam('sysparm_number', kbNumber);
ga.getXML(isSelfServiceParse);
}
else{
alert('This user is not an employee and does not have access to view KAs');
g_form.clearValue('comments');
}
}
function isSelfServiceParse(response) { //Verify responce is true and set comments if correct.
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer == "true") {
var comment = g_form.getValue('comments');
g_form.setValue("comments", comment.replace("kb_view.do?sys_kb_id", "sp?id=kb_article&sys_id"));
} else {
var userGA = new GlideAjax('getUserData');
userGA.addParam('sysparm_name', 'checkFulfiller');
userGA.addParam('sysparm_user_sys', g_form.getValue('caller_id'));
userGA.getXML(checkFulfillerParse);
}
}
function checkFulfillerParse(response) { //Display message if trying to attached an none self service article when the caller does not have access to the KB.
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer == "false") {
g_form.clearValue('comments');
alert("The KA you tried to attach is for fulfillers only. The caller cannot view this article.");
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2023 05:32 AM
Hi Brian,
Thank you for thinking along. A client script is not a solution because the URL is also communicated via email.
I need to find a way to directly change the URL that is communicated through the script include.