Create a button for Creating Incident article from INCIDENT form

Nandini DM
Tera Contributor

Hello,

 

We have a new template named "Incident article" that needs to be used when creating a knowledge article directly from an incident via button. Same as with a problem when creating a know error from problem form

How to achieve this using UI Action ?

 

Kindly help!

 

Thanks!

1 ACCEPTED SOLUTION

Bhavya11
Kilo Patron

Hi @Nandini DM,

Please create the UI action on incident table as "Incident article" if you want to show for specific state then add that in condition field like below

UI action :

Bhavya11_0-1719574994082.pngBhavya11_1-1719575007422.png

script 

 

Bhavya11_2-1719575028004.png

function confirmArticle() { // this is called from onclick fucntion 
    var answer = confirm("Are you sure you want create Knowledge from this incident.");
    if (answer == true) {
        gsftSubmit(null, g_form.getFormElement(), 'kbcidents');//kbcidents -this is action name of ui action
    } else {
        return false;
    }
}
if (typeof window == 'undefined')
    createKbFromIncident();

function createKbFromIncident() {

    var kbGr = new GlideRecord("kb_knowledge"); //copy the required fields that you want to show in the article 
    kbGr.initialize();
    kbGr.source = current.sys_id;
    kbGr.short_description = current.short_description;
    kbGr.text = kbGr.current.description;
    kbGr.insert();

    var link = '<a href="' + kbGr.getLink() + '">' + kbGr.getValue('number') + '</a>';
    var message = gs.getMessage('Knoweldge article cereated') + ' ' + link + ' ';
    gs.addInfoMessage(message); // this will display info message saying " Knoweldge article cereated KBnumber which has the link so that you direclty open from the incident.
    action.setRedirectURL(current);



}

 

 

output :

Bhavya11_3-1719575243736.png

Do the same for Problem table.

 

If my solution helps you any way then mark it as accepted and helpful.

 

Thanks,

BK

 

View solution in original post

9 REPLIES 9

Community Alums
Not applicable

Thank You @Bhavya11 . Solution works perfect.

Welcome 😊

ayanshnamde
Tera Contributor

ayanshnamde_0-1733382080128.png

I got this error, please Bhavya can you help me in this

Hi @ayanshnamde ,

 

open the ui action that you created please check the Action name field on that like in my case it is 'kbcidents'

 

Bhavya11_0-1733458752416.png

 

In the UI Action script, you need to pass the same name

gsftSubmit(null, g_form.getFormElement(), 'kbcidents');
 
 

If my solution helps you any way then mark it as accepted and helpful.

 

Thanks,

BK

Thanks, Bhavya it is working fine now.