Autocreate Incident and Incident task from Case.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2024 05:03 AM
Hi all,
My requirement is to create Incident and Incident Task for the below mentioned conditions from the case. So, the case table has a hidden field called 'Issue Type'.
- If Issue Type is Network --> Create Incident and map the fields.
- If Issue Type is Openreach --> Create Incident and Incident task and map the fields.
I tried this via BR but not able to the script logic correctly. Any help would be greatly appreciated.
Best Regards,
Sreesh Surendran
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2024 05:38 AM - edited 04-21-2024 01:49 AM
Hi @sreeshsurendran you will need to create a business rule for this, please share the script which you have attempted so far...
(function executeRule(current, previous /*null when async*/) {
if (current.issue_type == 'Network') {
var incidentGR = new GlideRecord('incident');
incidentGR.initialize()
incidentGR.short_description = current.short_description;
// Set other fields...
var incidentSysId = incidentGR.insert();
} else if (current.issue_type == 'Openreach') {
var incidentGR = new GlideRecord('incident');
incidentGR.initialize();
incidentGR.short_description = current.short_description;
// Set other fields...
var incidentSysId = incidentGR.insert();
var incidentTaskGR = new GlideRecord('incident_task');
incidentTaskGR.initialize();
incidentTaskGR.short_description = current.short_description;
var incidentTaskSysId = incidentTaskGR.insert();
}
})(current, previous);
☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2024 10:39 PM
Hi @Sohail Khilji ,
I've used a before BR on Insert and Update. Please find below the script I've attempted.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
if(!current.isActionAborted())
{
var incGr = new GlideRecord("incident");
var CalledFromBR = true;
if (current.incident.nil())
{
var CrInc = new CSMIncidentIntegrations_BT().copyFieldsFromCaseToIncident(incGr,current,CalledFromBR);
var incSysId = incGr.insert();
current.incident = incSysId;
}
}
if(current.u_issue_type == 'Openreach')
{
var inc = new GlideRecord('incident_task');
inc.initialize();
inc.short_description = current.short_description;
inc.assignment_group = current.assignment_group;
inc.incident = incGr.sys_id;
}
}
)(current, previous);