diff --git a/Server-Side Components/Business Rules/Automatically Populate Incident with Work Order Number/Populate_WorkOrder_Number_1.png b/Server-Side Components/Business Rules/Automatically Populate Incident with Work Order Number/Populate_WorkOrder_Number_1.png new file mode 100644 index 0000000000..be2999aa72 Binary files /dev/null and b/Server-Side Components/Business Rules/Automatically Populate Incident with Work Order Number/Populate_WorkOrder_Number_1.png differ diff --git a/Server-Side Components/Business Rules/Automatically Populate Incident with Work Order Number/Populate_WorkOrder_Number_2.png b/Server-Side Components/Business Rules/Automatically Populate Incident with Work Order Number/Populate_WorkOrder_Number_2.png new file mode 100644 index 0000000000..4d8437b946 Binary files /dev/null and b/Server-Side Components/Business Rules/Automatically Populate Incident with Work Order Number/Populate_WorkOrder_Number_2.png differ diff --git a/Server-Side Components/Business Rules/Automatically Populate Incident with Work Order Number/Populate_WorkOrder_Number_3.png b/Server-Side Components/Business Rules/Automatically Populate Incident with Work Order Number/Populate_WorkOrder_Number_3.png new file mode 100644 index 0000000000..99bb624d99 Binary files /dev/null and b/Server-Side Components/Business Rules/Automatically Populate Incident with Work Order Number/Populate_WorkOrder_Number_3.png differ diff --git a/Server-Side Components/Business Rules/Automatically Populate Incident with Work Order Number/README.md b/Server-Side Components/Business Rules/Automatically Populate Incident with Work Order Number/README.md new file mode 100644 index 0000000000..f26db80aac --- /dev/null +++ b/Server-Side Components/Business Rules/Automatically Populate Incident with Work Order Number/README.md @@ -0,0 +1,60 @@ +# Automatically Populate Incident with Work Order Number, State , OnHold Reason using business rule + +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 : +- Populates the Work Order reference (**u_work_order**) field on the parent Incident +- Sets the **Incident State → On Hold** +- Updates the **Hold Reason → Awaiting Field Work Order** +- Adds a **work note** in the Activity Stream for traceability + +This ensures a seamless connection between **ITSM** and **Field Service Management (FSM)** processes, allowing to identify related Work Orders without navigating to related lists. + +## Why This Use Case +Out-of-the-box (OOB) ServiceNow does **not** include a direct Work Order reference field on the Incident form. +By default, users can only view Work Orders under the *Related Tasks → Work Orders* section, which limits quick visibility. + +To address this gap, a custom reference field (**u_work_order**) was created under the **Related Records** section ( similar to *Problem* or *Parent Incident* ). +- Displays the linked Work Order number directly on the Incident form +- Prevents manual modification while maintaining clear visibility for agents + +## Process Alignment +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** + +When a Work Order is created from an Incident: +- The Incident automatically moves to **On Hold** +- The **Hold Reason** updates to *Awaiting Field Work Order* +- A **work note** logs the Activity Stream + +This behavior aligns with existing ITSM hold logic for Problem and Change processes + +## Prerequisites + +#### Ensure FSM Application Plugin is Installed +- This customization requires the Field Service Management (FSM) plugin to be installed and active in ServiceNow instance +- Search for Field Service Management plugin **com.snc.work_management** and install +- FSM provides the **Work Order [wm_order]** table + +#### Create a Custom Field on the Incident Table +- Create Custom Reference Field on Incident table with label name **Work Order** [u_work_order] and select Type as **Reference** +- Reference to Table Work Order [wm_order] +- Save and add this field to the **Incident form** under the **Related Records** section + +#### Add Custom Choice in On Hold Reason Field +- Navigate to hold_reason field on Incident table +- Configure dictionary and add **Awaiting Field Work Order** with value set as 2 and sequence as 5 +- Save the new choice to make it selectable in the *Hold Reason* field. + +--- +### Creating an Incident +![Create_Incident](Populate_WorkOrder_Number_1.png) + +--- + +### Work Order Created from Incident +![WorkOrder_From_Incident](Populate_WorkOrder_Number_2.png) + +--- + +### Incident Updated with Work Order Reference, State On Hold, and Reason Awaiting Field Work Order +![Populate_WorkOrderNumber_State_onHoldReason](Populate_WorkOrder_Number_3.png) + + diff --git a/Server-Side Components/Business Rules/Automatically Populate Incident with Work Order Number/businessRuleFsmUsecase.js b/Server-Side Components/Business Rules/Automatically Populate Incident with Work Order Number/businessRuleFsmUsecase.js new file mode 100644 index 0000000000..0251005e87 --- /dev/null +++ b/Server-Side Components/Business Rules/Automatically Populate Incident with Work Order Number/businessRuleFsmUsecase.js @@ -0,0 +1,22 @@ +(function executeRule(current, previous /*null when async*/) { + + if (!current.initiated_from.nil()) { + + var inc = new GlideRecord('incident'); + if (inc.get(current.initiated_from)) { + + // Link the Work Order reference to the Incident + inc.u_work_order = current.sys_id; + + // Move the Incident to On Hold and set Hold Reason + inc.state = 3; // 3 = On Hold + inc.hold_reason = '2'; // Awaiting Field Work Order (custom choice value created) + + // Add work note + inc.work_notes = 'Work Order ' + current.number + ' has been created and Incident moved to On Hold.'; + + inc.update(); + } + } + +})(current, previous);