|
| 1 | +# ServiceNow Approval Matrix Generator |
| 2 | +**A Dynamic, Data-Driven Approval Workflow Engine for ServiceNow** |
| 3 | + |
| 4 | +--- |
| 5 | + |
| 6 | +## Overview |
| 7 | + |
| 8 | +The **Approval Matrix Generator** is a configurable engine that automates approval generation in ServiceNow based on business rules — |
| 9 | +without hard-coding approvers or creating dozens of Flow Designer flows. |
| 10 | + |
| 11 | +By maintaining a simple **Approval Matrix table**, you can define which user or role should approve a request dynamically (e.g., based on department and amount). |
| 12 | +This approach provides scalability, maintainability, and full visibility across all approval logic. |
| 13 | + |
| 14 | +--- |
| 15 | + |
| 16 | +## Key Highlights |
| 17 | + |
| 18 | +✅ 100% native ServiceNow solution (no plugins) |
| 19 | +✅ Centralized approval logic in a single configuration table |
| 20 | +✅ Works for ITSM, HRSD, Finance, or Procurement workflows |
| 21 | +✅ Supports multi-level approvals (Manager → Director → CFO) |
| 22 | +✅ Can run via **Business Rule** |
| 23 | + |
| 24 | +--- |
| 25 | + |
| 26 | +## Use Case |
| 27 | + |
| 28 | +An organization wants dynamic approval routing for procurement or HR requests based on: |
| 29 | +- Department (IT, HR, Finance) |
| 30 | +- Request amount (₹0–₹10,000, etc.) |
| 31 | +- Approval role (Manager, Director, VP) |
| 32 | + |
| 33 | +Instead of building multiple flows, the Approval Matrix defines all rules in a single table. |
| 34 | +When a new request is submitted, the script automatically finds and assigns the correct approvers. |
| 35 | + |
| 36 | +--- |
| 37 | + |
| 38 | +## Step 1 — Create Table `u_approval_matrix` |
| 39 | + |
| 40 | +| Field | Type | Description | |
| 41 | +|--------|------|-------------| |
| 42 | +| **u_department** | Reference (sys_user_group) | Department owning the rule | |
| 43 | +| **u_min_amount** | Decimal | Minimum amount for range | |
| 44 | +| **u_max_amount** | Decimal | Maximum amount for range | |
| 45 | +| **u_role** | Choice | Role type – Manager / Director / VP | |
| 46 | +| **u_approver** | Reference (sys_user) | Direct approver (optional) | |
| 47 | + |
| 48 | +This table drives all the logic. |
| 49 | +Example data: |
| 50 | + |
| 51 | +| Department | Min | Max | Role | Approver | |
| 52 | +|-------------|-----|-----|------|-----------| |
| 53 | +| IT | 0 | 5000 | Manager | *(blank)* | |
| 54 | +| IT | 5000 | 10000 | Director | *(blank)* | |
| 55 | +| Finance | 0 | 10000 | *(blank)* | John CFO | |
| 56 | + |
| 57 | +--- |
| 58 | + |
| 59 | +## ⚙️ Step 2 — Business Rule Script |
| 60 | + |
| 61 | +**Table:** `sc_request` (or your custom table) |
| 62 | +**When:** After Insert |
| 63 | +**Condition:** Approval required |
| 64 | + |
| 65 | +## Example Input (Request Record) |
| 66 | +| Field | Value | |
| 67 | +| ------------- | ----------------- | |
| 68 | +| Requested For | Ravi Gaurav | |
| 69 | +| Department | IT | |
| 70 | +| Amount | 8000 | |
| 71 | +| Category | Hardware Purchase | |
| 72 | + |
| 73 | +## Example Output |
| 74 | +| Field | Value | |
| 75 | +| -------------------- | ----------------------------------------- | |
| 76 | +| Matched Rule | IT, 5000–10000, Role = Director | |
| 77 | +| Approver Found | Ravi’s Director (from `u_director` field) | |
| 78 | +| Approval State | Requested | |
| 79 | +| sysapproval_approver | Created Automatically | |
0 commit comments