Create a problem record when current short description matches

Rajkumar Bommal
Tera Contributor

Create a problem record

when current short description of an incident record matches to other incident records in the list
using scripting

 

2 REPLIES 2

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Rajkumar Bommal 

 

What is the use case of same? Genrally we have open to create problem record manually after checking the facts, in your case, if conditions matches it will create problem record and there are many PRB with same short description and can create a issue for you. 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Maddysunil
Kilo Sage

@Rajkumar Bommal 

You can write after insert business rule, Below is the script :

 

(function executeRule(current, previous /*null when async*/) {
    var shortDescription = current.short_description.getDisplayValue();
    
    // Query for other Incident records with the same short description
    var incidentGr = new GlideRecord('incident');
    incidentGr.addQuery('short_description', shortDescription);
    incidentGr.addQuery('sys_id', '!=', current.sys_id); // Exclude the current record
    incidentGr.query();
    
    if (incidentGr.hasNext()) {
        // Create a Problem record
        var problemGr = new GlideRecord('problem');
        problemGr.initialize();
        problemGr.short_description = 'Multiple Incidents with same description';
        problemGr.insert();
        
        gs.info('Problem record created for matching Incidents.');
    }
})(current, previous);

 

Please Mark Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.

 

Thanks