Need help with Incident Management business rule script (Beginner)

DaramK
Giga Contributor

Hi everyone

I'm a beginner in ServiceNow development, currently learning the Incident Management module.

I would like to create a 'business rule' that automatically sets the 'Assignment Group' when the 'Category'is "Hardware".

Here’s what I’ve tried so far:

```javascript
if (current.category == "hardware") {
current.assignment_group = "Hardware Support";
}

2 ACCEPTED SOLUTIONS

MC30
Tera Guru

Hi @DaramK ,

 

Script is not required for this however as you are new you need to know fe things. As "assignment_group" is a reference field you need to pass the "sys_id" of the assignmnet group. So, as Servicenow best practice we will not hardcode any sys_id in a code. So you need to store the sys_id of the group in a system property and call it in a business rule. Below are the steps to do it:

 

1. Open the required group record > right click on top of the headermenu > copy the sys_id

2. Go to System Properties > Create New > provide the name as you wish example "x_incident.group" > Type as string > and value will be the copied sys_id.

3. Below is the Business rule:

if (current.category == 'hardware') {
        var groupSysId = gs.getProperty('x_incident.group');
        if (groupSysId) {
            current.assignment_group = groupSysId;
        }

 

If my response helped please mark it correct or Helpful.

Regards,
Madhuri

View solution in original post

Ankur Bawiskar
Tera Patron
Tera Patron

@DaramK 

no scripting required.

you can use before insert/update business rule

Condition: Category == Hardware

Use Set Field Values Tab and set the group

Something like this

AnkurBawiskar_0-1753098081628.png

 

AnkurBawiskar_1-1753098093267.png

 

OR

In your above script set the group sysId

if (current.category == "hardware") {
current.assignment_group = "groupSysId";
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

2 REPLIES 2

MC30
Tera Guru

Hi @DaramK ,

 

Script is not required for this however as you are new you need to know fe things. As "assignment_group" is a reference field you need to pass the "sys_id" of the assignmnet group. So, as Servicenow best practice we will not hardcode any sys_id in a code. So you need to store the sys_id of the group in a system property and call it in a business rule. Below are the steps to do it:

 

1. Open the required group record > right click on top of the headermenu > copy the sys_id

2. Go to System Properties > Create New > provide the name as you wish example "x_incident.group" > Type as string > and value will be the copied sys_id.

3. Below is the Business rule:

if (current.category == 'hardware') {
        var groupSysId = gs.getProperty('x_incident.group');
        if (groupSysId) {
            current.assignment_group = groupSysId;
        }

 

If my response helped please mark it correct or Helpful.

Regards,
Madhuri

Ankur Bawiskar
Tera Patron
Tera Patron

@DaramK 

no scripting required.

you can use before insert/update business rule

Condition: Category == Hardware

Use Set Field Values Tab and set the group

Something like this

AnkurBawiskar_0-1753098081628.png

 

AnkurBawiskar_1-1753098093267.png

 

OR

In your above script set the group sysId

if (current.category == "hardware") {
current.assignment_group = "groupSysId";
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader