Create a problem record when current short description matches
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2024 03:07 AM
Create a problem record
when current short description of an incident record matches to other incident records in the list
using scripting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2024 03:18 AM
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]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2024 03:20 AM
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