How to downgrade incident priority using a run script on a transform map?

thrsdy1512
Tera Expert

Hi

I am working with a type of incident which is created by being transformed through a transform map and I want to prevent Critical incidents from being created. 

 

Any incident that comes in that is Critical should be downgraded to High instead. Is the best way to do this is via a run script on the transform map?

 

 

 

 

 

1 REPLY 1

Amitoj Wadhera
Kilo Sage

 

Hi @thrsdy1512 ,

 

Yes, using a script on the transform map is an effective way to achieve this. By adding a script to your transform map, you can manipulate the data before it is inserted into the target table. Here's a step-by-step approach to implement this:

  1. Open the Transform Map:

    • Navigate to System Import Sets > Administration > Transform Maps.
    • Open the relevant transform map.
  2. Add a Script:

    • In the transform map, locate the Field Maps section.
    • Add a new field map or edit an existing one for the priority field (assuming priority is the field indicating the incident's severity).
  3. Write the Script:

    • Use a script to check the value of the priority and downgrade it if it is set to Critical.

Here is an example script that you can use:

 

 

(function transformEntry(source, target, map, log, isUpdate) {
    // Check if the priority field in the source data is 'Critical'
    if (source.priority === 'Critical') {
        // Change the target priority to 'High'
        target.priority = 'High';
    } else {
        // Otherwise, set the target priority to the source priority
        target.priority = source.priority;
    }
})(source, target, map, log, isUpdate);

 

 

 

If you find my response helpful, please consider marking it as the 'Accepted Solution' and giving it a 'Helpful' rating. Your feedback not only supports the community but also encourages me to continue providing valuable assistance.

 

Thanks,

Amitoj Wadhera