- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Need to find the similar incidents based on short description or configurtion item. If found the similar incidents create a problem ticket with those incidents numbers and ci value. And attach the incidents and ci's in the related list of the problem ticket. And need to create a schelude on weekly basis to avoid duplication of problem ticket creation. This is the use case for creation of Agentic AI. Pls help me how to achive this.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 weeks ago
(function execute(inputs, outputs) {
// ----------------------------
// 1. Read primary incident NUMBER
// ----------------------------
var primaryNumber = String(inputs.primary_incident_sys_id || '');
if (!primaryNumber) {
outputs.status = "error";
outputs.message = "Primary incident number missing.";
return;
}
// ----------------------------
// 2. Parse similar incidents (STRING → ARRAY)
// ----------------------------
var numbers = [];
var similar = inputs.similar_incident_sys_ids;
if (typeof similar === 'string') {
try {
similar = JSON.parse(similar);
} catch (e) {
similar = [];
}
}
if (Array.isArray(similar)) {
for (var i = 0; i < similar.length; i++) {
if (similar[i].recordNumber)
numbers.push(String(similar[i].recordNumber));
}
}
if (numbers.indexOf(primaryNumber) === -1)
numbers.push(primaryNumber);
if (!numbers.length) {
outputs.status = "error";
outputs.message = "No incidents provided.";
return;
}
// ----------------------------
// 3. Get PRIMARY incident
// ----------------------------
var primaryInc = new GlideRecord('incident');
if (!primaryInc.get('number', primaryNumber)) {
outputs.status = "error";
outputs.message = "Primary incident not found.";
return;
}
var shortDesc = String(primaryInc.short_description);
// ----------------------------
// 4. Find existing Problem by short_description
// ----------------------------
var chosenProblemId = "";
var chosenProblemNumber = "";
var isNew = false;
var prbGR = new GlideRecord('problem');
prbGR.addQuery('short_description', shortDesc);
prbGR.orderByDesc('sys_created_on');
prbGR.setLimit(1);
prbGR.query();
if (prbGR.next()) {
chosenProblemId = prbGR.getUniqueValue();
chosenProblemNumber = String(prbGR.number);
}
// ----------------------------
// 5. Create Problem if NOT found
// ----------------------------
if (!chosenProblemId) {
var newPrb = new GlideRecord('problem');
newPrb.initialize();
newPrb.short_description = shortDesc;
newPrb.description =
"Auto-created from Virtual Agent\n\n" +
"Primary Incident: " + primaryNumber + "\n\n" +
"Related Incidents:\n" + numbers.join("\n");
newPrb.cmdb_ci = primaryInc.cmdb_ci;
newPrb.priority = primaryInc.priority;
chosenProblemId = newPrb.insert();
chosenProblemNumber = String(newPrb.number);
isNew = true;
}
// ----------------------------
// 6. Attach ALL incidents
// ----------------------------
var linkedNumbers = [];
var incGR = new GlideRecord('incident');
incGR.addQuery('number', 'IN', numbers.join(','));
incGR.query();
while (incGR.next()) {
incGR.problem_id = chosenProblemId;
incGR.update();
linkedNumbers.push(String(incGR.number));
}
// ----------------------------
// 7. Outputs
// ----------------------------
outputs.problem_number = chosenProblemNumber;
outputs.problem_sys_id = chosenProblemId;
outputs.is_new_problem = isNew;
outputs.incidents_linked = linkedNumbers;
outputs.status = "success";
if (isNew) {
outputs.message =
"A new Problem " + chosenProblemNumber +
" has been created and all related incidents have been successfully linked.";
} else {
outputs.message =
"Similar incidents have been successfully associated with existing Problem " +
chosenProblemNumber + ".";
}
})(inputs, outputs);
use this script as a flow action , it will all similar incident to prb
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello @sai9845 ,
1. Use
• Virtual Agent / Now Assist Panel triggers automation
2. Similarity Engine (OOTB Subflow – Get Similar Records)
• Retrieves primary Incident
• Matches by CI, category, and short description
• Returns similar active Incidents
3. Processing Layer (Custom Flow Action)
• Checks for existing Problem
• Creates new Problem if required
• Links all matched Incidents using problem_id
4. Output Layer
• Problem updated/created
• Incidents attached
• Status returned to user
Virtual Agent → Similarity Subflow → Attach Action → Problem record → Linked Incidents
I am already doing this use case , ping me if you want to more help.
Regards,
Umesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
How can I connect with you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
How Can I reach you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Need more help on this umesh. How can I reach you.
