Modify 'Create Incident' button output

scwillson
Mega Guru

I am attempting to modify the "Create Incident' button from the Knowledge Article view.

My Goal

My knowledge article form is going to have a custom form section that dictates the categorization and template that a given INC record is pre-loaded with when clicking on the 'Create Incident' button.

For example: If there is KB article about troubleshooting Outlook mail configuration. The article's form would have fields that define the Incident categorization (CI = "Outlook), or reference a template.

Need Assistance with Jelly

I've been able to find where the 'Create Incident' button is defined; UI Macro: kb_view_common_header_toolbar. However, I am very unfamiliar with jelly. The button is defined on line 45, but I don't see how to add to or modify it's onClick (or equivalent) function. There are also two other UI Macros that look like they might have something to do with it; kb_view_common and kb_view_hidden_fields.

Any input or assistance would be much appreciated.

1 ACCEPTED SOLUTION

scwillson
Mega Guru

I've been able to achieve my goal by modifying a system property, thanks to some feedback from Brad Foolhey.



Before modifying the system property, you must first create custom fields on the KB record form. These fields are what will carry through to the Incident when the "Create Incident" button is clicked for that specific article. For my example, I've created a field on the KB record form called u_inc_ci.



Modify system property glide.knowman.create_incident_link



Basically, the value of this property is the URL that generates and populates the new INC record, so you can just add the field values that you want. use the following format: incident_field_value=$[HTML:knowledgeRecord.knowledge_field_value]



So when modified to include my "u_inc_ci" field to dictate the cmdb_ci field on the incident form, it would look like this:


incident.do?sys_id=-1&sysparm_query=active=true^cmdb_ci=$[HTML:knowledgeRecord.u_inc_ci]^comments=(Created after Knowledge search: $[HTML:knowledgeRecord.short_description])&sysparm_stack=knowledge_home_launcher.do

View solution in original post

23 REPLIES 23

srinivasthelu
Tera Guru

Hi Simon,



Look at this UI Script "KBViewArticle"



Especially, this piece.




incidentBtnHandler: function (event) {


var loc = $j('#createIncidentLinkLocation').val();


if (loc && loc.length) {


window.location = loc;


}


},




Hope this helps


Srini





Thank you for replying Srinivas, but that piece of code doesn't mean anything to me. I doesn't look like something I can use to modify the behavior of the 'create incident' button. (unless it is just my naivety with jelly scripting)


Hi Simon,



That is where the redirection is happening to incident form.



Per say, If i want to redirect the users to https://www.google.com after the clicking on the 'Create incident' button, I would change the code to



incidentBtnHandler: function (event) {


window.location = "https://www.google.com";


},




Hope that helps



Please mark this response as helpful/correct if it is so.



Thanks


Srini


I've been trying to work with this, and I have another question for you.



Do you know how I would be able to reference the "current" Knowledge article that this button is on when clicked?


I've tried 'current' and 'this' with various combinations of '.number' or '.sys_id', but to no avail...