Skip to content

Commit 1106276

Browse files
authored
Automatically Populate Incident with Work Order Number (#2452)
* Create README.md * Add files via upload * Create businessRuleFsmUsecase.js * Update README.md Changes made as requested
1 parent cc067f9 commit 1106276

File tree

5 files changed

+82
-0
lines changed

5 files changed

+82
-0
lines changed
96.8 KB
Loading
75.2 KB
Loading
93.9 KB
Loading
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Automatically Populate Incident with Work Order Number, State , OnHold Reason using business rule
2+
3+
This use case automates the linkage between **Work Orders** and **Incidents** in ServiceNow. When a **Work Order** is created from an **Incident**, the system automatically :
4+
- Populates the Work Order reference (**u_work_order**) field on the parent Incident
5+
- Sets the **Incident State → On Hold**
6+
- Updates the **Hold Reason → Awaiting Field Work Order**
7+
- Adds a **work note** in the Activity Stream for traceability
8+
9+
This ensures a seamless connection between **ITSM** and **Field Service Management (FSM)** processes, allowing to identify related Work Orders without navigating to related lists.
10+
11+
## Why This Use Case
12+
Out-of-the-box (OOB) ServiceNow does **not** include a direct Work Order reference field on the Incident form.
13+
By default, users can only view Work Orders under the *Related Tasks → Work Orders* section, which limits quick visibility.
14+
15+
To address this gap, a custom reference field (**u_work_order**) was created under the **Related Records** section ( similar to *Problem* or *Parent Incident* ).
16+
- Displays the linked Work Order number directly on the Incident form
17+
- Prevents manual modification while maintaining clear visibility for agents
18+
19+
## Process Alignment
20+
In standard ITSM workflows, Incidents can be placed **On Hold** for reasons such as *Awaiting Problem*, *Awaiting Change*, or *Awaiting Vendor*. Since there was no default option for Field Service, this customization introduces a new Hold Reason : **Awaiting Field Work Order**
21+
22+
When a Work Order is created from an Incident:
23+
- The Incident automatically moves to **On Hold**
24+
- The **Hold Reason** updates to *Awaiting Field Work Order*
25+
- A **work note** logs the Activity Stream
26+
27+
This behavior aligns with existing ITSM hold logic for Problem and Change processes
28+
29+
## Prerequisites
30+
31+
#### Ensure FSM Application Plugin is Installed
32+
- This customization requires the Field Service Management (FSM) plugin to be installed and active in ServiceNow instance
33+
- Search for Field Service Management plugin **com.snc.work_management** and install
34+
- FSM provides the **Work Order [wm_order]** table
35+
36+
#### Create a Custom Field on the Incident Table
37+
- Create Custom Reference Field on Incident table with label name **Work Order** [u_work_order] and select Type as **Reference**
38+
- Reference to Table Work Order [wm_order]
39+
- Save and add this field to the **Incident form** under the **Related Records** section
40+
41+
#### Add Custom Choice in On Hold Reason Field
42+
- Navigate to hold_reason field on Incident table
43+
- Configure dictionary and add **Awaiting Field Work Order** with value set as 2 and sequence as 5
44+
- Save the new choice to make it selectable in the *Hold Reason* field.
45+
46+
---
47+
### Creating an Incident
48+
![Create_Incident](Populate_WorkOrder_Number_1.png)
49+
50+
---
51+
52+
### Work Order Created from Incident
53+
![WorkOrder_From_Incident](Populate_WorkOrder_Number_2.png)
54+
55+
---
56+
57+
### Incident Updated with Work Order Reference, State On Hold, and Reason Awaiting Field Work Order
58+
![Populate_WorkOrderNumber_State_onHoldReason](Populate_WorkOrder_Number_3.png)
59+
60+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
(function executeRule(current, previous /*null when async*/) {
2+
3+
if (!current.initiated_from.nil()) {
4+
5+
var inc = new GlideRecord('incident');
6+
if (inc.get(current.initiated_from)) {
7+
8+
// Link the Work Order reference to the Incident
9+
inc.u_work_order = current.sys_id;
10+
11+
// Move the Incident to On Hold and set Hold Reason
12+
inc.state = 3; // 3 = On Hold
13+
inc.hold_reason = '2'; // Awaiting Field Work Order (custom choice value created)
14+
15+
// Add work note
16+
inc.work_notes = 'Work Order ' + current.number + ' has been created and Incident moved to On Hold.';
17+
18+
inc.update();
19+
}
20+
}
21+
22+
})(current, previous);

0 commit comments

Comments
 (0)