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

Hi Laurent,

Thanks for your reply. The requirement is about creating a button on knowledge article(Agent Workspace) that will send an email that has a link to the knowledge article. The email will be automatically addressed to the contact in agent workspace and i will be able to add additional emails in the "To", "CC" and "BCC".

The Search Action Configuration I was refering to can be configured to select the field in which the article link is added ("Attach note field").

From there maybe you could attach the link in a custom field that display a form section with the required configuration for the recipients of the email and any other required inputs. Then you could have a business rule that collects this information, trigger an event and then wipe the fields for the next use of the attach button.

On the same idea, maybe the custom field could be always hidden, and you could have a onChange client script on that field that would open a modal window to collect the inputs and then trigger the event for the notification using a GlideAjax. I haven't used agent workspace modals but they are documented here https://docs.servicenow.com/bundle/rome-servicenow-platform/page/administer/workspace/task/set-up-ui-action-render-custom-component.html and more extensively here (not official documentation) https://www.ashleysn.com/post/workspace-ui-actions

Hi Laurent,

 

I have similar requirement to add Email button on kb article on portal.

can you please give details on how to configure it

 

Thank you!

Rutuja

Nicole_k
Kilo Expert

Hi All,
I have a very similar question which I have been struggling to get assistance with.
We have the issue where we prefer out customer use the portal and not the desktop view. Our Itil users are struggling to get the idea of sending them a link to the portal KBA and not the kb_view.do. I know I have to update kb_view_common_header_toolbar similar to above.

Ultimately I would like a button that displays only if the KBA Knowledge base is "General".  Label "Copy portal link"

On click it needs to do something like copyToClipboard(window.location.origin + "/sp?id=kb_article&sys_id=" + sys_id);

I am not knowledgeable in XML and have wasted a lot of digging trying to find a solution.