Skip to content

Latest commit

Β 

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”§ Tool Lending Library β€” ServiceNow Scoped Application

Built entirely with ServiceNow Build Agent for the #BuildWithBuildAgent Challenge

A full-featured equipment lending management system built on the ServiceNow platform, featuring role-based access control, automated loan workflows, email notifications, overdue detection, and custom React-based UI Pages β€” all generated through conversational AI in a single session.


πŸ“‹ Table of Contents


Overview

The Tool Lending Library is a ServiceNow scoped application that manages an equipment lending operation β€” think of it like a library, but for tools and machinery. It supports two user personas:

Persona Role Capabilities
Librarian / Staff x_828868_tool_le_0.librarian Full access: add/edit equipment, approve/deny borrow requests, check items in/out, mark items for maintenance, manage members, view all loans
Member x_828868_tool_le_0.member Limited access: browse equipment catalog, view own loans, submit borrow requests (pending staff approval)

Architecture

graph TD
    subgraph "πŸ‘€ Roles"
        R1["πŸ”‘ Librarian<br/><i>Full Access</i>"]
        R2["πŸ”‘ Member<br/><i>Limited Access</i>"]
        R1 -->|contains| R2
    end

    subgraph "πŸ—„οΈ Data Model"
        T1["πŸ“¦ Equipment<br/><i>name, category, serial#,<br/>condition, status, photo</i>"]
        T2["πŸ‘₯ Members<br/><i>name, email, phone,<br/>membership status, user link</i>"]
        T3["πŸ“‹ Loan Record<br/><i>equipment, member, dates,<br/>status, approved_by</i>"]
        T3 -->|"equipment ref"| T1
        T3 -->|"member ref"| T2
        T2 -->|"user ref"| SU["πŸ§‘ sys_user"]
    end

    subgraph "βš™οΈ Automation"
        BR1["πŸ“œ Enforce Pending Status<br/><i>Before Insert</i>"]
        BR2["πŸ“œ Prevent Member Modification<br/><i>Before Update</i>"]
        SS["⏰ Flag Overdue Loans<br/><i>Daily @ 1:00 AM</i>"]
        EN1["πŸ“§ Request Submitted"]
        EN2["πŸ“§ Loan Approved"]
        EN3["πŸ“§ Overdue Notice"]
    end

    subgraph "πŸ–±οΈ UI Actions"
        UA1["βœ… Approve Request"]
        UA2["❌ Deny Request"]
        UA3["πŸ“₯ Mark as Returned"]
        UA4["πŸ”§ Send to Maintenance"]
        UA5["πŸ“€ Request to Borrow"]
    end

    subgraph "πŸ–₯️ UI Pages"
        P1["πŸ“Š Staff Dashboard<br/><i>Pending Β· Active Β· Overdue</i>"]
        P2["πŸ“– Member Catalog<br/><i>Browse & Request Equipment</i>"]
    end
Loading

Data Model

Equipment Table (x_828868_tool_le_0_equipment)

Field Type Required Description
name String (100) βœ… Name of the equipment item
category Choice β€” Hand Tool Β· Power Tool Β· Machinery Β· Other
serial_number String (100) β€” Serial or asset tracking number
condition Choice β€” Good Β· Fair Β· Needs Repair (default: Good)
status Choice β€” Available Β· Checked Out Β· In Maintenance (default: Available)
photo String (200) β€” Photo attachment reference

Members Table (x_828868_tool_le_0_members)

Field Type Required Description
name String (100) βœ… Full name of the member
contact_email Email β€” Contact email address
contact_phone String (20) β€” Contact phone number
membership_status Choice β€” Active Β· Inactive (default: Active)
user Reference β†’ sys_user β€” Link to ServiceNow user account
user_role Choice β€” Member Β· Librarian (default: Member)

Loan Record Table (x_828868_tool_le_0_loan_rec)

Field Type Required Description
equipment Reference β†’ Equipment βœ… The equipment item being borrowed
member Reference β†’ Members βœ… The member borrowing the item
checkout_date DateTime β€” Set when loan is approved
due_date DateTime β€” Expected return date
return_date DateTime β€” Actual return date (null until returned)
status Choice β€” Pending Approval Β· Active Β· Returned Β· Overdue
approved_by Reference β†’ sys_user β€” Librarian who approved the request

Roles & Security

Role Hierarchy

Librarian (x_828868_tool_le_0.librarian)
  └── contains β†’ Member (x_828868_tool_le_0.member)

Access Control Rules (12 ACLs)

Equipment Table

Operation Librarian Member
Read βœ… All records βœ… All records
Create βœ… ❌
Write βœ… ❌
Delete βœ… ❌

Members Table

Operation Librarian Member
Read βœ… All records ⚠️ Own record only
Create βœ… ❌
Write βœ… ❌
Delete βœ… ❌

Loan Record Table

Operation Librarian Member
Read βœ… All records ⚠️ Own loans only
Create βœ… Any status ⚠️ Pending Approval only
Write βœ… All records ⚠️ Own + Pending only
Delete βœ… ❌

⚠️ Row-level security enforced via ACL scripts using current.member.user == gs.getUserID()


Workflow & Automation

Loan Lifecycle State Machine

stateDiagram-v2
    [*] --> PendingApproval: Member submits request
    PendingApproval --> Active: Librarian approves
    PendingApproval --> [*]: Librarian denies (record deleted)
    Active --> Overdue: Daily scheduled job (due date passed)
    Active --> Returned: Librarian marks returned
    Overdue --> Returned: Librarian marks returned
    Returned --> [*]
Loading

Business Rules

Rule Timing Action Purpose
Enforce Pending Status for Members Before Insert Forces pending_approval Prevents members from bypassing approval
Prevent Member Status Modification Before Update Aborts save with error Blocks members from editing approved/active loans

Scheduled Script

Name Frequency Time Purpose
Flag Overdue Loans Daily 1:00 AM Queries active loans past due date β†’ sets status to overdue

UI Actions

Button Table Visibility Role Action
βœ… Approve Request Loan Record Status = Pending Approval Librarian Sets status β†’ Active, records approved_by, sets checkout_date, updates equipment β†’ Checked Out
❌ Deny Request Loan Record Status = Pending Approval Librarian Deletes the loan record, redirects to list
πŸ“₯ Mark as Returned Loan Record Status = Active or Overdue Librarian Sets status β†’ Returned, records return_date, updates equipment β†’ Available
πŸ”§ Send to Maintenance Equipment Status β‰  In Maintenance Librarian Sets equipment status β†’ In Maintenance
πŸ“€ Request to Borrow Equipment Status = Available Member Prompts for due date, creates loan record with Pending Approval status, looks up member by logged-in user

UI Pages

πŸ“Š Staff Dashboard

A React-based dashboard for librarians featuring:

  • Summary Cards β€” Real-time counts of Pending Approvals, Active Loans, and Overdue Items (fetched via Table API with X-Total-Count header)
  • Three Filtered Record Lists β€” Using NowRecordListConnected with key prop filtering:
    • Pending Approvals (status=pending_approval)
    • Active Loans (status=active)
    • Overdue Items (status=overdue)
  • Design Token Theming β€” Uses --now-* CSS variables for Horizon Design System compliance

Tech Stack: React 18.2.0 Β· @servicenow/react-components Β· ServiceNow Table API Β· Horizon Design Tokens

πŸ“– Member Catalog

A React-based equipment browsing interface for members featuring:

  • Welcome Header β€” Title and instructions for browsing equipment
  • Equipment List β€” NowRecordListConnected showing name, category, condition, and status columns
  • Row Navigation β€” Clicking equipment opens the standard form where the "Request to Borrow" button is available
  • Clean Design β€” Styled with Horizon Design System tokens for platform consistency

Email Notifications

Notification Trigger Recipient Subject
Borrow Request Submitted Loan Record inserted with pending_approval Member (via member.user) "Borrow Request Submitted - {equipment}"
Loan Approved Loan Record updated to active Member (via member.user) "Loan Approved - {equipment}"
Loan Overdue Notice Loan Record updated to overdue Member (via member.user) "OVERDUE: {equipment} - Please Return Immediately"

File Structure

x_828868_tool_le_0/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ client/                          # React UI Pages
β”‚   β”‚   β”œβ”€β”€ staff-dashboard/
β”‚   β”‚   β”‚   β”œβ”€β”€ index.html               # HTML entry with Polaris + Array.from polyfill
β”‚   β”‚   β”‚   β”œβ”€β”€ main.tsx                 # React bootstrap
β”‚   β”‚   β”‚   β”œβ”€β”€ app.tsx                  # Dashboard component (summary cards + filtered lists)
β”‚   β”‚   β”‚   └── styles.css               # Horizon design token styling
β”‚   β”‚   β”œβ”€β”€ member-catalog/
β”‚   β”‚   β”‚   β”œβ”€β”€ index.html               # HTML entry
β”‚   β”‚   β”‚   β”œβ”€β”€ main.tsx                 # React bootstrap
β”‚   β”‚   β”‚   β”œβ”€β”€ app.tsx                  # Catalog browsing component
β”‚   β”‚   β”‚   └── styles.css               # Horizon design token styling
β”‚   β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   β”‚   └── fields.ts                # display() and value() field helpers
β”‚   β”‚   └── tsconfig.json                # TypeScript configuration
β”‚   └── fluent/                          # ServiceNow Fluent DSL definitions
β”‚       β”œβ”€β”€ roles.now.ts                 # Librarian + Member roles
β”‚       β”œβ”€β”€ tables.now.ts                # Equipment, Members, Loan Record tables
β”‚       β”œβ”€β”€ acls.now.ts                  # 12 ACL rules (read/create/write/delete Γ— 3 tables)
β”‚       β”œβ”€β”€ business-rules.now.ts        # Enforce pending status + prevent modification
β”‚       β”œβ”€β”€ ui-actions.now.ts            # 5 UI Actions (approve, deny, return, maintenance, borrow)
β”‚       β”œβ”€β”€ notifications.now.ts         # 3 email notifications
β”‚       β”œβ”€β”€ scheduled-script.now.ts      # Daily overdue detection job
β”‚       β”œβ”€β”€ flag-overdue-loans.js        # IIFE script for overdue flagging
β”‚       β”œβ”€β”€ nav.now.ts                   # Application menu + 6 navigator modules
β”‚       └── ui-pages/
β”‚           β”œβ”€β”€ staff-dashboard.now.ts   # Staff Dashboard UiPage definition
β”‚           └── member-catalog.now.ts    # Member Catalog UiPage definition
β”œβ”€β”€ package.json
β”œβ”€β”€ now.config.json
└── tsconfig.json

What Build Agent Created

In a single conversational session, Build Agent generated:

Category Count Details
Roles 2 Librarian (with role inheritance), Member
Tables 3 Equipment, Members, Loan Record (with references)
Columns 19 String, Choice, Email, Reference, DateTime types
ACLs 12 Read/Create/Write/Delete for all 3 tables with script-based row-level security
Business Rules 2 Insert enforcement + update protection
UI Actions 5 Approve, Deny, Return, Maintenance, Borrow (with client+server patterns)
Email Notifications 3 Request submitted, approved, overdue
Scheduled Scripts 1 Daily overdue detection
UI Pages 2 React-based Staff Dashboard + Member Catalog
Navigation 7 1 Application Menu + 6 modules (3 lists, 1 separator, 2 direct links)
Total Metadata Records 64 Installed in one deployment

Build Stats

  • βœ… Zero build errors on final compilation
  • βœ… Zero UI diagnostics errors β€” both pages load cleanly
  • βœ… All API calls return 200 β€” Table API and GraphQL queries verified
  • βœ… Horizon Design System compliant β€” CSS design tokens validated

πŸ† #BuildWithBuildAgent

This application was built entirely through natural language conversation with ServiceNow's Build Agent β€” no manual coding, no form-based configuration, no copy-pasting. From initial requirements to a fully deployed, production-ready application with role-based security, automated workflows, email notifications, and custom React UIs.

The future of ServiceNow development is conversational.

About

Tool/Equipment Lending Library for ServiceNow #BuildWithBuildAgent challenge

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors