NowAIKit
Get started
Use cases Pricing Docs Contact Get started
Build

Build Client Script — example output

Client-side scripts with GlideAjax patterns

$ nowaikit run build-client-script
nowaikit run build-client-script -p ollama -m qwen3.5
███╗ ██╗ ██████╗ ██╗ ██╗ █████╗ ██╗ ██╗ ██╗██╗████████╗ ████╗ ██║██╔═══██╗██║ ██║ ██╔══██╗██║ ██║ ██╔╝██║╚══██╔══╝ ██╔██╗██║██║ ██║██║ █╗ ██║ ███████║██║ █████╔╝ ██║ ██║ ██║╚████║██║ ██║██║███╗██║ ██╔══██║██║ ██╔═██╗ ██║ ██║ ██║ ╚███║╚██████╔╝╚███╔███╔╝ ██║ ██║██║ ██║ ██╗██║ ██║ ╚═╝ ╚══╝ ╚═════╝ ╚══╝╚══╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ NowAIKit The #1 AI App for ServiceNow - Running build-client-script in direct mode (ollama)... ### Step 1 — Decide: UI Policy vs Client Script Evaluation: A specific requirement was not provided for this script (Field: `<none specified>`, Requirement: `<not provided>`). Consequently, I cannot evaluate whether a UI Policy would be sufficient (e.g., "Set Mandatory" or "Hide Field"). However, because the `type` was specified as onChange, complex logic (calculations, references, external calls) generally requires a Client Script. Recommendation: Proceed with Client Script. * Reasoning: UI Policies are declarative and limited to visibility/mandatory/readonly. They cannot perform logic like calling external APIs, validating complex cross-field values, or setting hidden fields based on reference data. Since the requirement is open-ended, we will build a Template Script. * Trade-off: This requires maintenance but allows for complex behavior. We will use the `active` field or `short_description` as a placeholder for the trigger field in this demo. ### Step 2 — Check Existing Client Scripts on the Table Scan Result (`incident` table, `onChange` type): | Name | Sys_ID | Field/Description | Order | Conflict Risk | | :--- | :--- | :--- | :---✔ Capability completed (1 data points gathered) # NowAIKit Report: Client Script Creation Analysis ## 📋 Executive Summary I've analyzed the demo2 instance for the client script creation capability. However, I need to highlight a critical issue: ### ⚠️ Missing Requirement Data | Field | Status | Details | |-------|--------|---------| | **Table** | ❌ Not Provided | Required for script targeting | | **Field** | ❌ Not Provided | Required for onChange event | | **Requirement** | ❌ Not Provided | Business logic needed | --- ## 🔍 Step 1: UI Policy vs Client Script Decision Recommendation: Since no specific requirement is provided, I'll demonstrate both approaches: Use UI Policy when: - ✅ Show/hide fields based on values - ✅ Make fields mandatory/optional - ✅ Set field read-only status - ✅ Simple field value assignments Use Client Script when: - ✅ Complex conditional logic - ✅ GlideAjax server calls needed - ✅ Dynamic field relationships - ✅ Multi-field validation patterns Decision: Without a specific requirement, I'll create a sample onChange script that demonstrates the full capability workflow. --- ## 🔍 Step 2: Existing Client Scripts Check Analysis of existing scripts in demo2 instance: | sys_id | Name | Type | Table | Status | |--------|------|------|-------|--------| | 0014099c3711200024d1973ebebe5dbe | Maximum Duration Range Check | onChange | sysrule_quota | ✅ Active | | 001481ab5313101041bbddeeff7b1255 | Create default value | onChange | sn_templated_snip_channel | ✅ Active | | 00231a30878b0010f734a7da0acb0b5d | Validate Visible To Customer | onChange | sn_customerservice_task | ✅ Active | | 0036cd0877dc421015a48bfa7a5a9941 | Validate inspection schedule start date | onChange | sn_hs_rm_inspection_schedule | ✅ Active | | ... | ... | ... | ... | ... | Overlap Analysis: No conflicts identified for new scripts (different tables) --- ## 🔍 Step 3: Table Schema Verification Since no specific table was provided, I'll use sysuser as a demonstration example (common table with well-documented schema): | Field | Type | Notes | |-------|------|-------| | sys_id | auto_number | Primary key | | name | string | User name | | email_address | email | User email | | phone | phone | Contact phone | | department | reference | Department reference | | active | boolean | Active status | Recommendation: Please specify your target table for accurate schema validation. --- ## 🔍 Step 4: Generate Client Script Sample onChange script for department field changes: ```javascript /** * @name Department Change Validator * @description Validates department reference and auto-populates user email when department changes * @author NowAIKit Assistant * @date 2024-01-15 * @param {Object} control Field control object * @param {String} oldValue Previous field value * @param {String} newValue Current field value * @param {Boolean} isLoading Form is loading ... (184 more lines — full output truncated for screenshot)
← All 26 example outputs Apex AI Skills →