Create KB from INC/RITM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hello All,
We have a requirement where
- Check if the INC or RITM is assigned to groupa or groupb.
- When the INC/RITM is resolved /close completed, display dialog if they wnat to create a KB for that ticket
- if user says yes then create KG or open KB portal with the specified category
Looking for help and steps to achieve this.
TIA
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
then simply handle this in the OOTB BR on incident table which does this
Add condition for Group A or Group B in the BR
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi @CV1 ,
I tried your problem in my PDI please check below solution
I created a Client script OnChange - state and added below code
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var sysId = g_form.getUniqueValue();
alert("Here");
// Incident states
if (newValue != 6 && newValue != 7){
alert("State is " + newValue);
return;
}
var ga = new GlideAjax('CreateKBArticle');
ga.addParam('sysparm_name', 'shouldPromptKB');
ga.addParam('sysparm_table', "incident");
ga.addParam('sysparm_sys_id', sysId);
ga.getXMLAnswer(function(answer) {
alert("Inside Answer = " + answer);
if (answer !== 'true')
return;
var ask = confirm("Do you want to create a Knowledge Article for this ticket?");
if (ask) {
openKB();
}
});
}
function openKB() {
var url =
'/kb_knowledge.do?sys_id=-1' +
'&sysparm_query=' +
'kb_knowledge_base=a7e8a78bff0221009b20ffffffffff17' +
'^kb_category=ed1c2552ff0131009b20ffffffffff65' +
'^source=' + g_form.getUniqueValue();
g_navigation.open(url);
}
I created a Script Include, client callable and added below code
var CreateKBArticle = Class.create();
CreateKBArticle.prototype = Object.extendsObject(AbstractAjaxProcessor, {
shouldPromptKB: function () {
var table = this.getParameter('sysparm_table');
var sysId = this.getParameter('sysparm_sys_id');
var gr = new GlideRecord(table);
if (!gr.get(sysId))
return "false";
var allowedGroups = [
'8a4dde73c6112278017a6a4baf547aa7',
'287ee6fea9fe198100ada7950d0b1b73'
];//software, database
if (!gr.assignment_group || allowedGroups.indexOf(gr.assignment_group.toString()) === -1)
return "false";
if (table === 'incident') {
if (gr.state != 6 && gr.state != 7) // Resolved / Closed
return "false";
}
if (table === 'sc_req_item') {
if (gr.state != 3) // Closed Complete
return "false";
}
return "true";
},
type: 'CreateKBArticle'
});
Result
Currently this Inc is in IN Progress state when I change to Closed it ask me create KB Article
It will navigate me to KB Article
Please mark my answer correct and helpful if this works for you
Thanks and Regards,
Sarthak