System should not allow creating a duplicate record from incident table and display error message

Anusha Gorige
Tera Contributor
 
2 ACCEPTED SOLUTIONS

praneeth7
Tera Guru

Hi @Anusha Gorige 

 

Assuming that the duplicate record will be calculated based on Short description, In that case you can use before BR in Incident table.

var shortDesc = current.short_description;

var inc = new GlideRecord('incident');
inc.addQuery('short_description', shortDesc);
inc.query();
if(inc.next()){
gs.addErrorMessage('eg:Incident with same SD already exsit');
current.setAbortAction();
}

If this helps you please mark my answer Helpful and Accepted solution,

Thank you.

View solution in original post

Nivedita Patil
Mega Sage
Mega Sage

Hi @Anusha Gorige ,

 

This script for calculating duplicate record based on short description and caller.

 

Use before  business rule.

Table: incident and  When to run: insert (selected)

 

Write  below script in advanced section:

 

var gr= new GlideRecord('incident');

gr.addQuery('short_description', current.short_description);

gr.addQuery('caller_id', current.caller_id);

gr.query();

if(gr.next()){

current.setAbortAction(true);

gs.addErrorMessage('you can not create new record as you already have existing one')

}

 

Mark my answer correct and helpful if helps you.

 

Thanks,

Nivedita Patil.

View solution in original post

4 REPLIES 4

praneeth7
Tera Guru

Hi @Anusha Gorige 

 

Assuming that the duplicate record will be calculated based on Short description, In that case you can use before BR in Incident table.

var shortDesc = current.short_description;

var inc = new GlideRecord('incident');
inc.addQuery('short_description', shortDesc);
inc.query();
if(inc.next()){
gs.addErrorMessage('eg:Incident with same SD already exsit');
current.setAbortAction();
}

If this helps you please mark my answer Helpful and Accepted solution,

Thank you.

Nivedita Patil
Mega Sage
Mega Sage

Hi @Anusha Gorige ,

 

This script for calculating duplicate record based on short description and caller.

 

Use before  business rule.

Table: incident and  When to run: insert (selected)

 

Write  below script in advanced section:

 

var gr= new GlideRecord('incident');

gr.addQuery('short_description', current.short_description);

gr.addQuery('caller_id', current.caller_id);

gr.query();

if(gr.next()){

current.setAbortAction(true);

gs.addErrorMessage('you can not create new record as you already have existing one')

}

 

Mark my answer correct and helpful if helps you.

 

Thanks,

Nivedita Patil.

Jim Coyne
Kilo Patron

I see that you've marked the 2 previous answer as being correct, and they will do what you are asking for, but I question the requirement.  Do you really, seriously, want to do that?

 

What exactly is a "duplicate" Incident?  Can't really be based just on the Short description.  What if someone does have the same issue?  Are you going to force your agents to come up with a slightly different Short description in order to save the record ("Wireless mouse problem", "Wireless mouse problem2", "Wireless mouse problem3" [OK, not the best example, but you get it])?

 

What if I have the same issue with my wireless mouse, but 2 months between the issues?  You have no details on the requirement that could help us understand why you are asking for this.  You have to be careful of the requirements.    So many questions on this one.

 

Remember, TNT: The Customer is NOT Always Right.

Avinash Uskamal
Tera Contributor

before  business rule.

Table: incident and  When to run: insert

 

var gr= new GlideRecord('incident');

gr.addQuery('short_description', current.short_description);

gr.addQuery('caller_id', current.caller_id);

gr.query();

if(gr.hasNext()){  //to check least one record present

current.setAbortAction(true);

gs.addErrorMessage('you can not create new record as you already have existing one')

}

 

Mark my answer correct and helpful if helps you.

 

Regards,

Avinash Uskamalla