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

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Nandini DM 

 

Not sure, why you want to duplicate the functionality. In Inc we have check box if that tick / true an article get created. I can understand you have specific need but request you to see if you can modify that Check box module for yoru need. 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

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

 

Thank you Bhavya 😀

Welcome😄