Duplicate incident creation restriction in servicenow

nitin51
Tera Contributor

Hi team, how to stop duplicate incident creation using fields. if suppose, created by, opened by, few words in short description and description matches. we need to restrict the duplicate incident creation. please help me on this.

11 REPLIES 11

Alok Das
Tera Guru

Hi Nitin,

Create a before insert business rule with below script:

(function executeRule(current, previous /*null when async*/ ) {

    var gr = new GlideRecord('incident');
    gr.addActiveQuery();
    gr.addEncodedQuery('short_description>=' + current.short_description + '^ORshort_description<=' + current.short_description + '^ORdescription>=' + current.description + '^ORdescription<=' + current.description);
    gr.addQuery('opened_by', current.opened_by);
    gr.addQuery('caller_id', current.caller_id);
    gr.query();
    if (gr.next()) {
        current.setAbortAction(true);
        gs.addErrorMessage('Duplicate incident creation, You already have a similar incident with number:' + gr.number);
    }
})(current, previous);

 

Kindly mark my answer as Correct and Helpful based on the Impact.

Regards,

Alok

nitin51
Tera Contributor

thanks for your quick response,

 

what I want is only if one sentence in description field is matched then it should not create duplicate

EX: for one ticket this is description

Description -- " LIKE is an operator which will check if the field contains any value the same as the one we are giving"

 

again if another ticket description contains the underlined sentence or consecutive words like above, it should not create another ticket.

"field contains any value"  then new ticket should not create.

 

NOTE: only if underlined words are as is, then it should not create, if they are jumbled then ticket can create.