Business Rule to update Incident

Nisha30
Kilo Sage

Hi Team,

 

Please assist.

We want to update 1) Priority of Incident  based on combination of two fields cmdb_ci.attribute  and impact in Incident

example : if Impact = High and cmdb_ci.attibute = 1, THEN Incident priority =P1

likewise there are 4 combinations 

 

also i started with another piece to be added here

if cmdb_ci.support_group is NOT empty, then populate the Incident-Assignemnt group = cmdb_ci.support_group

 

Can someone please assist 

THanks

12 REPLIES 12

Abhay Kumar1
Giga Sage

@Nisha30 you can create a BR to run in insert or update with follow simple script:

if (current.impact == 'High' && current.cmdb_ci.attribute == 1) {

    current.priority = 1;

} else if (current.impact == 'High' && current.cmdb_ci.attribute == 2) {

    current.priority = 2;

} else if (current.impact == 'Medium' && current.cmdb_ci.attribute == 1) {

    current.priority = 3;

} else if (current.impact == 'Medium' && current.cmdb_ci.attribute == 2) {

    current.priority = 4;

}

 

if (!gs.nil(current.cmdb_ci.support_group)) {

    current.assignment_group = current.cmdb_ci.support_group;

}

Hope this will help you.

Hello Nisha,

 

Add your conditions in 'else if' and test

 

 

if (current.impact == 'high' && current.cmdb_ci.attribute == 1) {

    current.priority = 1;

} else if (condition 2) {

    current.priority = 2;

} else if (condition 3) {

    current.priority = 3;

} else if (condition 4) {

    current.priority = 4;

}

else{

//nothing

}

 

if (!gs.nil(current.cmdb_ci.support_group)) {

    current.assignment_group = current.cmdb_ci.support_group;

}

 

Please mark my solution as helpful

Hi @Abhay Kumar1 ,

Below is my code but it is not working

 

(function executeRule(current, previous /*null when async*/) {

if(cmdb_ci.attributes)
{
    if (current.impact == '1' && current.cmdb_ci.attributes.toLowerCase() == 'critical')
    {
        current.priority = 2;
        gs.log("<<Priority P2");
    } else if (current.impact == '2' && current.cmdb_ci.attributes.toLowerCase() == 'critical')
    {
        current.priority = 3;
        gs.log("<<Priority P3");
    } else if (current.impact == '3' && current.cmdb_ci.attributes.toLowerCase() == 'critical')
    {
        current.priority = 4;
        gs.log("<<Priority P4 with 3");
    } else if (current.impact == '4' && current.cmdb_ci.attributes.toLowerCase() == 'critical')
    {
        current.priority = 4;
        gs.log("<<Priority P4");
    }
    else
        {  
            gs.log("NO matching case from Moogsoft");
        }
}
else
{
    gs.log("<<No Attributes");
    if (current.impact == '1' && current.cmdb_ci.environment.toLowerCase() == 'production') //critical and production
    {
        current.priority = 3;
        gs.log("<<No Attributes but Environment");
    }
    else
    {
        current.priority = 4;
    }
}
if (!gs.nil(current.cmdb_ci.support_group))
{
    current.assignment_group = current.cmdb_ci.support_group;
}

})(current, previous);

Moin Kazi
Kilo Sage
Kilo Sage

Hi @Nisha30 ,

 

In ServiceNow, the Incident Table Priority is determined through Priority Lookup Rules, so you need to review and configure these rules accordingly.

As for your second requirement, there is already an Out-of-the-Box (OOB) Business Rule available that updates the Assignment Group based on the CMDB_CI.support_group.

MoinKazi_0-1730806741006.png

 

 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If you found my response **helpful**, I’d appreciate it if you could take a moment to select **"Accept as Solution"** and **"Helpful"** Your support not only benefits me but also enriches the community.

 

Thank you!
Moin Kazi
www.linkedin.com/in/moinuddinkazi

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~