If a ticket exists with the same short description that you have written in a new ticket, an alert message should come that this incident already exists and ticket should not get submitted.

sachingawas
Kilo Expert

If a ticket exists with the same short description that you have written in a new ticket, an alert message should come that this incident already exists and ticket should not get submitted. How can we do this

1 ACCEPTED SOLUTION

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Sachin,



Please refer the below script. You can write a business rule with the below script.


function onBefore(current, previous) {


  var gr = new GlideRecord('incident');


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


  gr.query();


  while(gr.next())


  {


  gs.addInfoMessage('Ticket already exists'); //Change the message as per your req.


  current.setAbortAction(true); //aborts the record


  }


}



I hope this helps


View solution in original post

2 REPLIES 2

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Sachin,



You can write a client script+ GlideAjax or the business rule which will abort the record submission.


Please let me know if you have any questions.


Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Sachin,



Please refer the below script. You can write a business rule with the below script.


function onBefore(current, previous) {


  var gr = new GlideRecord('incident');


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


  gr.query();


  while(gr.next())


  {


  gs.addInfoMessage('Ticket already exists'); //Change the message as per your req.


  current.setAbortAction(true); //aborts the record


  }


}



I hope this helps