For every 30 reopen count in incidents create a new problem ticket

mirza_saquib
Tera Contributor

As reopen count of incidents are increasing again and again and i need to create a problem ticket for every 30 reopen incident, that is the reopen count reaches 30 it create one problem ticket. When the same event comes again then the new event create and the reopen count in that incident reaches 30 new problem ticket create and the same is going on , please suggest any flow or something which helps to resolve the issue.

1 ACCEPTED SOLUTION

Pratiksha2
Mega Sage

Hello @mirza_saquib -
You can write after update Business rule ,

 

(function executeRule(current, previous /*null when async*/) {
    // Check if the incident has been reopened
    if (current.state == 2 && previous.state == 7) {
        // Increment the reopen count
        var reopenCount = current.reopen_count ;

        // Check if the reopen count is a multiple of 30
        if (reopenCount % 30 === 0) {
            // Create a new problem ticket
            var problemGr = new GlideRecord('problem');
            problemGr.short_description = 'Auto-generated problem ticket for multiple incident reopens';
            // Add any additional fields as needed
            var problemSysId = problemGr.insert();

            gs.info('Created a new problem ticket with Sys ID: ' + problemSysId);
        }
    }
})(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,

Pratiksha

View solution in original post

8 REPLIES 8

Pratiksha2
Mega Sage

Hello @mirza_saquib -
You can write after update Business rule ,

 

(function executeRule(current, previous /*null when async*/) {
    // Check if the incident has been reopened
    if (current.state == 2 && previous.state == 7) {
        // Increment the reopen count
        var reopenCount = current.reopen_count ;

        // Check if the reopen count is a multiple of 30
        if (reopenCount % 30 === 0) {
            // Create a new problem ticket
            var problemGr = new GlideRecord('problem');
            problemGr.short_description = 'Auto-generated problem ticket for multiple incident reopens';
            // Add any additional fields as needed
            var problemSysId = problemGr.insert();

            gs.info('Created a new problem ticket with Sys ID: ' + problemSysId);
        }
    }
})(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,

Pratiksha

Hi @Pratiksha2 ,

After this BR after 30 reopen incident problem ticket will create, If the problem get resolved this BR close the incident?

and if the same event trigger it will create new incident it repeats the above process?

Thanks & Regards

Mirza Saquib Beg

Hello @mirza_saquib ,

The provided Business Rule (BR) script is designed to create a new problem ticket in the ServiceNow platform when an incident is reopened and the reopen count reaches a multiple of 30. However, the script does not contain logic to automatically close the associated incident or create a new incident.

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

 

Thanks,

Pratiksha



Hi @Pratiksha2 

I need to customize the event property like currently the property is reopen alert will reopen the incident, So every time the alert reopen it will reopen the incident but I need to create the new incident  every time when the reopen count of incident reaches 30 or in other word the overall event count in alert field reaches to 31, then every time it will create the new incident . So is there any way to achieve this?