How to avoid duplicate knowledge article creation from incident?

RimaC
Tera Contributor

Does anyone know a good way to avoid the creation of duplicate KBs from incidents? Looking to eliminate the issue of having multiple KBs for the same type of incident. Any suggestions are appreciated.

1 ACCEPTED SOLUTION

Sohail Khilji
Kilo Patron
Kilo Patron

Hi @RimaC ,

 

You will need to create a before insert business rule which check for the subject and  other conditons which checks for duplicate KB creation and avoid the insertion and trow an error with an insert abort action.

 

 

(function executeRule(current, previous /*null when async*/) {
        var incidentShortDesc = current.getValue('short_description'); //considering short_desr to be the key , you can use any fieldwhich you wanted to check
        var kbArticleGr = new GlideRecord('kb_knowledge');
        kbArticleGr.addQuery('short_description', incidentShortDesc);
        kbArticleGr.query();
        
        if (kbArticleGr.hasNext()) {
            gs.addErrorMessage('A knowledge article with the same short description already exists.');
            current.setAbortAction(true); 
        }
 
})(current, previous);

 


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

View solution in original post

2 REPLIES 2

Sohail Khilji
Kilo Patron
Kilo Patron

Hi @RimaC ,

 

You will need to create a before insert business rule which check for the subject and  other conditons which checks for duplicate KB creation and avoid the insertion and trow an error with an insert abort action.

 

 

(function executeRule(current, previous /*null when async*/) {
        var incidentShortDesc = current.getValue('short_description'); //considering short_desr to be the key , you can use any fieldwhich you wanted to check
        var kbArticleGr = new GlideRecord('kb_knowledge');
        kbArticleGr.addQuery('short_description', incidentShortDesc);
        kbArticleGr.query();
        
        if (kbArticleGr.hasNext()) {
            gs.addErrorMessage('A knowledge article with the same short description already exists.');
            current.setAbortAction(true); 
        }
 
})(current, previous);

 


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect

Thank you @Sohail Khilji - we will explore that.