Add new button to Knowledge view

wchaiwimol
Giga Contributor

Is it possible to add a new button for example Create HR Case to the knowledge view? The functionality will be similar to Create Incident. Thanks in advance for your help.

find_real_file.png

1 ACCEPTED SOLUTION

Doing some Developper console exploring, I found that the script that handles the createIncident button reside in the UI Script "KBViewArticle"



So you have: $j('#createIncident').click(this.incidentBtnHandler.bind(this));which handles the click of the button



Then the incidentBtnHandler function uses $j('#createIncidentLinkLocation').val(); to set the location



The #createIncidentLinkLocation refers to an hidden input field which is contained inside "kb_view_hidden_fields" UI Macro.



This createIncidentLinkLocation is based on the System property (sys_properties.list in SNOW navigator). This link looks a lot like what I suggested which is: "incident.do?sys_id=-1&sysparm_query=active=true^comments=(Created after Knowledge search: $[HTML:knowledgeRecord.short_description])&sysparm_stack=knowledge_home_launcher.do"



The important part in the link is the "$[HTML:knowledgeRecord.short_description]" part. Inside "kb_..." UI Macro you have access to knowledgeRecord jelly object which contains all your knowledge fields which you may want to use for your predefined values.You usually can use it in first phase ${knowledgeRecord.field} or in second phase $[knowledgeRecord.field]



So if you want to create your button the same way the create incident is done you would need to customize:



  • 3 UI Macro (kb_view_common_header_toolbar & kb_view_hidden_fields & kb_view_common in which the variable showCreateIncident is initialized based on the fact that the knowledge is in a popup or not)
  • 1 UI Script (KBViewArticle)
  • Insert a new system property


This has the pro of respecting the actual design but have the con of making a lot of modifications that can be harder to maintain than simply putting a onclick on your button.



Depending on your level of expertise in ServiceNow and with Jelly, I think I gave you enough info to do it yourself, but if you need more help, just ask.


View solution in original post

33 REPLIES 33

Thanks laurentchicoine. We have confirmed this from ServiceNow.


Hi Laurent!


Im really in a need to get this button in to our environment, especially in to our 1st level supporters knowledge base.


What do you mean by the "J release" ? Is that code name for Istanbul or what?



Thanks for reply!


br. Anna


J release is the Jakarta release that is following Istanbul.



It will be announced at Knowledge17 which is next week.



So unless this is really urgent to you, I would recommend to wait for your upgrade to that version.


Yeah of course it is Jakarta..how stupid of me.
It is just that according to our dev team we are gonna update to Istanbul approx in Sep 2017, so i assume we will be waiting for the J for at least over a year from now


Hi Laurent,



Can you help me out regarding this below Question. Thanks in Advance!



https://community.servicenow.com/thread/273301



Thanks,


Arindam