Create Knowledge button on incident form

sfoleygo
Kilo Explorer

Looking for some help adding a Create Knowledge button on the Incident form. I know I have to create a UI action but have minimal JavaScript knowledge.   I'm hoping someone can share some code with me to accomplish this or show me which "create new" ui action code I can modify. I don't want to use the KB checkbox that is on the form by default because our IT users are checking the box which may provide an incident solution but the results are not formatted as we would like.   We want to provide the user's with the option to create and edit a knowledge article on the fly when working within an incident. We also want the knowledge article available immediately. Right now we have our resolve to close window set at 7 days and the knowledge article is not created until the incident actually closes.

2 REPLIES 2

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Susan,



Basically there is a BR "Incident Create Knowledge" which gets triggered based on the checkbox selected on the form. However you can copy the same code and adjust as per your req as part of UI action. Here is the script you can use.


var kb = new GlideRecord("kb_knowledge");


      kb.source = current.sys_id;


      kb.short_description = current.short_description;


      kb.sys_domain = current.sys_domain;


      kb.text = current.comments.getHTMLValue();


      kb.workflow_state = 'draft';


  kb.kb_knowledge_base = gs.getProperty("glide.knowman.task_kb", "dfc19531bf2021003f07e2c1ac0739ab");


      kb.insert();


      gs.addInfoMessage(gs.getMessage('Knowledge Article created') + ':   ' + kb.number + ' ' + gs.getMessage('based on closure of Incident') + ': ' + current.number);




Please let me know if you are blocked.


Thanks Pradeep.  


That works. I now have a button and an option in the contect menu to "Create Knowledge" and it works just like checking the default Knowledge checkbox on the Incident form. I would like the UI action to work more like "create problem" or "create change" where a separate window opens and allows the user to create the knowledge article from the knowledge form. That way it's not just capturing the additional comments, but the user can add screenshots and write clear documentation for issues. Our IT folks are checking the Knowledge box and we end up with a lot of knowledge articles lacking the details needed to be useful documentation. Ideally, it would carry over the short description and additional comments that the support person could makes some quick edits to and be done quickly. We don't want them having to recreate the wheel but to get in the habit of creating useful articles. Hope that makes sense.


Thanks,


Susan