If short description is same as current short description,then user must not be able to save inciden

Shubham_verma
Tera Contributor

When user tries to enter short description on incident form,if short description is same as recently entered short description,then user must not be able to submit incident.How can we achieve this?

3 ACCEPTED SOLUTIONS

Hi @Shubham_verma 

Try this

(function executeRule(current, previous /*null when async*/) {
var grIncident = new GlideRecord('incident');
grIncident.addQuery("short_description",current.short_description);
grIncident.query();
if (grIncident.next()) {
    current.setAbortAction(true);
}
})(current, previous);
 
Make sure you have not applied any condition on when to run section
 
Please mark help if this resolves your query
Thanks!

View solution in original post

@Shubham_verma 
The script will take the SD value that you're entering, with all the incidents present in the system, if the SD matches with any other incident's SD, then it will not allow you to save the incident, however, if no SD matches then it will allow you to save the incident.

View solution in original post

@Shubham_verma  , when you update XYZ to XYZ , there wont be any difference right Shubam 

Technically when you update from XYZ to YZA and then when you update YZA to XYZ in next update it throughs error

 

Regards,

Shyamkumar 

 

Please mark this as helpful and accept as a solution if this resolves your Ask.
Regards,

Shyamkumar

View solution in original post

12 REPLIES 12

@Shubham_verma  , How did you perform Testing ?

 

So when you create an INC giving Short description as XYZ and if this SD already Exists it aborts the Submission 

 

if you want the same for Update as well enable update Operation as well

 

add gs.log to check if BR is triggering or not 

 

Regards,

Shyamkumar

 

Please mark this as helpful and accept as a solution if this resolves your Ask.
Regards,

Shyamkumar

The code you provided is working fine when creating a new incident & update incident but,

when I open a existing incident & SD is XYZ .When I again write XYZ in SD its getting saved.I wanted to abort if I write same SD as written earlier on existing incident.It should not get saved.

@Shubham_verma  , when you update XYZ to XYZ , there wont be any difference right Shubam 

Technically when you update from XYZ to YZA and then when you update YZA to XYZ in next update it throughs error

 

Regards,

Shyamkumar 

 

Please mark this as helpful and accept as a solution if this resolves your Ask.
Regards,

Shyamkumar