Assistance with building Business Rule condition in a Script Include

Steven Watts2
Tera Guru

Hi,

I have a requirement to run a business rule when either of the following scenarios occur on the Incident table:

1)

Record is inserted AND

Service offering is 1,2,3,4 or 5 

2) 

Record is updated and Service offering changes

Service offering changes to 1,2,3,4 or 5 but was NOT previously 1,2,3,4 or5 

I.e., don't run if the previous Service offering was one of the 5, even if the change is to another of the 5. Only run when changing to one of these 5 and the previous isn't one of them.

 

My problem is that to write that in the condition field would be too long. I therefore want to generate the filter in a script include and then call it. I've done this before with reference qualifiers however unsure how to get it working with a BR condition.

 

Does anyone have any examples of where they have done something similar?

 

Steven

1 ACCEPTED SOLUTION

Hemanth M1
Giga Sage
Giga Sage

Hi @Steven Watts2 ,

 

Create BR with condition insert or update, annd check additional logic in  insert and update block as below

Change service_offering with your actual service_offering field backend value and also verify if its 1 or "1" while comaparing values

	if (current.operation() == "insert" && (current.service_offering =1 ||current.service_offering =2|| current.service_offering =3 || current.service_offering =4 ||current.service_offering =5)) {
		//do the following
	}

	else if(current.operation() == "update" && (current.service_offering.changes()) && (previous.service_offering !=1 ||previous.service_offering !=2 || previous.service_offering !=3 ||previous.service_offering !=4 ||previous.service_offering !=5)){
//do the logic
}

 

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

View solution in original post

4 REPLIES 4

Hemanth M1
Giga Sage
Giga Sage

Hi @Steven Watts2 ,

 

Create BR with condition insert or update, annd check additional logic in  insert and update block as below

Change service_offering with your actual service_offering field backend value and also verify if its 1 or "1" while comaparing values

	if (current.operation() == "insert" && (current.service_offering =1 ||current.service_offering =2|| current.service_offering =3 || current.service_offering =4 ||current.service_offering =5)) {
		//do the following
	}

	else if(current.operation() == "update" && (current.service_offering.changes()) && (previous.service_offering !=1 ||previous.service_offering !=2 || previous.service_offering !=3 ||previous.service_offering !=4 ||previous.service_offering !=5)){
//do the logic
}

 

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

Thanks @Hemanth1 

 

I'll give this a go and confirm back.

 

Steven

Hi @Steven Watts2 ,

 

did it work?? if so,

 

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

Hi @Hemanth M1 

 

Apologies, completely forgot to respond. I had to make a couple of tweaks but yeah this worked, thanks for the assistance.

 

Steven