- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2016 04:27 PM
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.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2016 03:44 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2016 03:44 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-03-2016 09:09 AM
Hi Laurent,
Thank you very much for your response. I'll take a stab at it. Your explanation was very helpful. If I get stuck, I'll probably need your help.
Michael
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-13-2017 11:15 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2017 08:17 AM
Hi laurentchicoine, I want to add a "Subscribe" button there. When clicked, a record should be entered in a custom table which will store knowledge article & Subscribers linking. And if anybody has subscribed already, he should see "Unsubscribe" button, when clicked record should be deleted from that table. Is it possible to do this all in just "kb_view_common_header_toolbar" macro? If yes, how?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2017 08:45 AM
Hi Rushikesh,
I wouldn't implement that if it is not urgent to you. I've heard (unconfirmed) that this functionality would be added in the J release.