Interested in a ServiceNow event built for developers? Registration for now[dev]26 is officially open!

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

Not applicable

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);

 

View solution in original post

2 REPLIES 2

Not applicable

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);

 

Thank you @Community Alums - we will explore that.