i have an issue in business rule

shubsharma6
Tera Contributor

i have understood the concept but unable make up the scenaio pls guide 

 

 

3 REPLIES 3

J Siva
Tera Sage

Hi @shubsharma6 
[Generated by Co-pilot]

Here are some practical scenarios that demonstrate how Business Rules are used in ServiceNow to automate server-side logic:


🔄 1. Automatically Set Incident State on Assignment

Scenario: When an incident is assigned to a group, set its state to "In Progress".

Business Rule Setup:

  • Table: Incident
  • When: Before
  • Condition: current.assignment_group.changes()
  • Script:
  current.state = 2; // In Progress

📧 2. Send Notification When Priority is Critical

Scenario: If an incident's priority is set to "Critical", notify the on-call team.

Business Rule Setup:

  • Table: Incident
  • When: After
  • Condition: current.priority == 1
  • Script:
  gs.eventQueue('incident.critical_priority', current, current.sys_id, gs.getUserID());

🔒 3. Prevent Deletion of Closed Incidents

Scenario: Block users from deleting incidents that are already closed.

Business Rule Setup:

  • Table: Incident
  • When: Before Delete
  • Condition: current.state == 7 // Closed
  • Script:
  gs.addErrorMessage('Closed incidents cannot be deleted.');
  current.setAbortAction(true);

🧾 4. Copy Caller Info to a Custom Field

Scenario: When a new incident is created, copy the caller's department to a custom field.

Business Rule Setup:

  • Table: Incident
  • When: Before Insert
  • Script:
  var user = new GlideRecord('sys_user');
  if (user.get(current.caller_id)) {
    current.u_caller_department = user.department;
  }

🕒 5. Log Time When State Changes to Resolved

Scenario: Track when an incident is resolved by storing the timestamp in a custom field.

Business Rule Setup:

  • Table: Incident
  • When: Before Update
  • Condition: current.state.changesTo(6) // Resolved
  • Script:
  current.u_resolved_time = new GlideDateTime();

 

Ankur Bawiskar
Tera Patron
Tera Patron

@shubsharma6 

what's your actual question?

If you enroll in any now learning course for scripting, there you will get lot of use-case scenarios.

You can also ask AI tools and they can help you with scenarios for you to learn

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

SD_Chandan
Kilo Sage

Hi @shubsharma6 ,

You can refer this article :-
https://www.servicenow.com/community/developer-articles/my-collected-list-of-useful-business-rules/t...

well explained you will definitely get clarity after reading it..

Mark it helpful if this helps you to understand. Accept solution if this give you the answer

Thank you
Chandan