Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Conditional Logic for Incidents

sseverance
Tera Contributor

Hello community members! This may sound like a very simple question but I am new to ServiceNow development. How would I set up conditional logic for Incidents? Specifically, if the short description contains "Incident INC-1 opened" then assign it to a specific group. One of the challenges is the number will consistently increment by one every time a new Incident is created. Any help here is appreciated!

1 ACCEPTED SOLUTION

Tanushree Maiti
Kilo Patron

Hi @sseverance 

Here Best approach is to use a Before Business Rule in ServiceNow.

  • Table: Incident 
  • Name: Assign Special Group by Pattern
  • Advanced: Checked
  • Insert: Checked
  • Update: Checked

Trigger Condition:

Short description starts with "Incident INC-" AND

Short description end with "Opened"

(Better would be apply regex  using condition builder //refer : https://www.youtube.com/watch?v=KDDrnKeU-JU)

 

then using script , set the assignment group value.

 

 

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin:

View solution in original post

See our ServiceNow services here: https://www.beyond20.com/servicenow-consultation See our Cherwell services here: https://www.beyond20.com/cherwell-consulting Digital Transformation Blog: https://www.beyond20.com/blog/ beyond20.com
3 REPLIES 3

Sujit Jadhav
Tera Guru

Hello @sseverance ,

1.Create a new Assignment Rule
Table: Incident

Condition:
Short description contains Incident INC-


OR


2.Business Rule
Table: Incident
When: Before
Insert: Checked

Script:
(function executeRule(current, previous) {

if (current.short_description &&
current.short_description.indexOf('Incident INC-') > -1) {

current.assignment_group = 'YOUR_GROUP_SYS_ID';
}

})(current, previous);



"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"

Thank You,

Sujit Jadhav

AndersBGS
Tera Patron

Hi @sseverance 

 


As @Sujit Jadhav  have mentioned you can utilize assignment rule based on condition. Please remember, to have an assignment rule based on a string field is in general not good practice as string can change to have a space, an additional character or so fourth - so you solution will not be very resilient.

 

If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.

Best regards
Anders

Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/

Tanushree Maiti
Kilo Patron

Hi @sseverance 

Here Best approach is to use a Before Business Rule in ServiceNow.

  • Table: Incident 
  • Name: Assign Special Group by Pattern
  • Advanced: Checked
  • Insert: Checked
  • Update: Checked

Trigger Condition:

Short description starts with "Incident INC-" AND

Short description end with "Opened"

(Better would be apply regex  using condition builder //refer : https://www.youtube.com/watch?v=KDDrnKeU-JU)

 

then using script , set the assignment group value.

 

 

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin:
See our ServiceNow services here: https://www.beyond20.com/servicenow-consultation See our Cherwell services here: https://www.beyond20.com/cherwell-consulting Digital Transformation Blog: https://www.beyond20.com/blog/ beyond20.com