The CreatorCon Call for Content is officially open! Get started here.

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

i have Before , Insert and Update Business Rule and gave 50 as Order still priority stuff not working.

 

The second stuff assignment group BR that works thanks for pointing out that even though i did not have in my instance took it from PDI but works.

@Nisha30 

 

Please read the info at the link I posted. The Priority Data lookup runs after Before BRs with order less than 1000. And fix you first "if" statement like I posted below.

Bert_c1
Kilo Patron

Hi @Nisha30 

I tested your script logic. The following worked for me. I set Order to 1001, changed the first line to have  if (current.cmdb_ci.attributes).  The complete script follows.

 

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

	// Add your code here
	if(current.cmdb_ci.attributes)
	{
		gs.log("<<Impact = " + current.impact + ", attributes = " + current.cmdb_ci.attributes.toLowerCase());
		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))
	{
		gs.log("<<Setting assignment_group");
		current.assignment_group = current.cmdb_ci.support_group;
	}

})(current, previous);

 

try the above. And make sure the CI selected has 'critical' in the attributes field on that record.