Accessing Now Assist in the Script Editor
In any script field (Business Rules, Script Includes, Client Scripts, Scheduled Jobs, etc.), look for the Now Assist icon in the script editor toolbar. If the plugin is activated and you have the now_assist_user role, the icon is visible. If it is not visible, check plugin activation and role assignment — see the activation guide.
Code generation from comments
Type a comment describing what you want the code to do, place your cursor after the comment, and trigger generation:
// Query all active incidents assigned to the current user
// ordered by priority, limit to 10, return as array of objects with number and description
// Now Assist generates a suggestion here
// Review before accepting
Now Assist generates code based on the comment. Review it before accepting — it will not know your specific custom fields, naming conventions, or business logic. Treat it as a starting point that eliminates boilerplate, not a finished solution.
Code explanation
Select existing code in the editor and use the "Explain" option. Now Assist returns a plain-English explanation of what the selected code does. Most valuable for:
- Understanding inherited scripts from previous developers
- Reviewing complex regex or encoded query logic
- Onboarding new team members to existing codebase
- Quick documentation of undocumented logic
What it is good at
- Standard GlideRecord query patterns and filters
- Common utility functions (date formatting, string manipulation)
- Boilerplate Script Include structure
- Simple transform map scripts
- Standard REST API call patterns
What it struggles with
- Custom business logic specific to your instance — it does not know your custom fields, tables, or workflows
- Complex multi-table queries with specific join conditions
- Instance-specific naming conventions
- Anything that requires understanding your organisation's specific process or data model
Review everything before committing
Treat Now Assist code suggestions like Stack Overflow answers — they are a starting point that eliminates initial scaffolding, not a final answer. Before committing any generated code to an Update Set:
- Verify table and field names match your instance
- Check that the logic matches your actual requirements
- Add error handling that the generated code may have omitted
- Test in a sub-production environment
Related guides: Now Assist overview · Script Includes · Debugging scripts
How code generation works in the Script Editor
The Now Assist code generation panel appears as a side panel in the ServiceNow Script Editor. You describe what you want in plain English — "Write a Business Rule that fires after an incident is saved, checks if priority is 1, and sends an email to the assignment group manager" — and the AI generates the full script. The generated code follows ServiceNow conventions: it uses GlideRecord for queries, gs utilities for logging, and standard Business Rule patterns for the execution context.
Code quality and review requirements
AI-generated code should always be reviewed before committing to an Update Set, the same way you would review code from any junior developer. Common issues to check for: missing setLimit() on GlideRecord queries that might run on large tables, hardcoded sys_ids that should be system properties, missing error handling around external calls, and logic that is correct for the described scenario but misses edge cases specific to your instance's configuration.
The code generation is strongest for common patterns — standard ITSM queries, notification scripts, straightforward Business Rules — and weakest for complex multi-step logic or instance-specific integrations it has no context about. Use it as a starting point and productivity accelerator, not as a replacement for understanding what the code does.
Code explanation — reverse mode
The explanation feature works in reverse: paste an existing script and ask "What does this do?" The AI explains the logic in plain English, which is useful when inheriting undocumented legacy code. It is also useful for learning — paste a pattern you found in the community, read the explanation, understand why it works the way it does. This reverse mode is often underused compared to generation but delivers consistent value for developers working in existing codebases.
Related: Now Assist overview · Activation · Debugging scripts · Interview questions · Script Includes
Effective prompting for code generation
The quality of AI-generated ServiceNow code is directly proportional to the specificity of your description. Vague: "Write a Business Rule for incidents." Better: "Write an async Business Rule on the incident table that fires after save when priority changes to 1. It should query the sys_user_group table to find the group manager's email, then send a notification using gs.eventQueue with event name 'incident.p1.escalation', passing the manager's user sys_id as parameter 1 and the assignment group name as parameter 2."
Include in your description: the table, the trigger type (before/after/async), the specific condition, what API to use, the outcome, and any constraints (setWorkflow(false) for bulk operations, use getValue not toString, etc.). Treat the AI like a junior developer who needs a detailed ticket — the more context you provide, the less the result will need to be rewritten. For complex multi-step logic, break it into separate prompts rather than trying to generate everything in one request.
Code generation for non-developer team members
One of the less-discussed applications of Now Assist code generation is enabling technically-inclined admins to write their first scripts. An admin who understands what they want a Business Rule to do, but has not written GlideRecord code before, can describe the logic in plain English and get a working starting point. The risk: admins who deploy AI-generated code without understanding it cannot debug it when it fails or adapt it when requirements change. The mitigation: establish a review process where a developer reviews any AI-generated code before it is committed to an Update Set, and require that the person who prompts the AI can explain what the generated code does line by line before it goes to production.
This is not about gatekeeping — it is about quality. AI-generated code that no one on your team understands is technical debt. AI-generated code that serves as a learning scaffold, with the human understanding the logic after generation, is a productivity accelerator. Encourage the latter, discourage the former through your review process design.
Limitations of current code generation
Now Assist code generation is strongest for common patterns on standard tables and weakest for complex logic, custom table structures, or instance-specific configuration it has no knowledge of. It does not know your specific custom fields, custom tables, or your organisation's coding conventions unless you include that context in your prompt. For a complex integration with a proprietary internal API, the generated code will be structurally correct but will need significant customisation for your specific endpoints and data structures. Set expectations accordingly: code generation is a first-draft accelerator, not a finished product, and the productivity gain is largest on standard patterns where the generated code needs minimal modification.
Code generation and the CAD certification
The CAD exam tests ability to write and understand ServiceNow scripts — code generation does not help you pass it because the exam tests your knowledge, not your tools. Understand the patterns behind generated code, not just how to generate it. A developer who can read any script and explain what it does — including one they generated — is significantly more capable than one who can only generate scripts through AI prompts. Use code generation to accelerate your learning: generate a pattern, study it, understand every line, then write a variation from scratch without the AI. This approach builds the underlying knowledge that the exam and senior technical interviews test.
Prompt templates for common ServiceNow patterns
Keep a library of prompts that reliably generate high-quality code for common patterns. Examples: "Write an async Business Rule on [table] that fires after save when [field] changes to [value]. Log the change to the System Log with the record number, old value, and new value. Use getValue() not toString()." "Write a client-callable Script Include method that accepts a [field] parameter, queries [table] where [condition], and returns the results as a JSON array of objects with fields [list]." These templates encode the context (use getValue, client callable, return JSON) that generates better output and reduces editing time. Build your team's prompt library collectively — each developer's effective prompts are knowledge worth sharing.
Code generation is a productivity tool, not a knowledge replacement. The most effective users are developers who understand what they are generating well enough to review, adapt, and debug it. Used that way, it is one of the most practical AI features ServiceNow has shipped — tangible time savings on routine scripting work that frees cognitive capacity for the complex problems that genuinely require human expertise.
The Now Assist developer features require the now_assist_user role and must be on the Xanadu release or later. If the code generation panel does not appear in your Script Editor, verify both conditions: role assigned to your user, and the com.sn_now_assist_dev plugin active on the instance. See the activation guide for the plugin activation sequence and common troubleshooting steps.
Now Assist code generation is most valuable when integrated into your team's development workflow from day one rather than adopted ad-hoc. Define the review process, the prompt library, and the documentation requirements for AI-generated code before your team starts using it heavily. These decisions are much harder to retrofit after habits have formed. A well-governed code generation practice produces higher-quality output and builds better developer judgment; an ungoverned one produces technical debt at AI speed.
Code generation in ServiceNow represents a genuine productivity improvement for developers who use it well. The key is treating it as a first draft tool — fast, useful, requiring review — rather than a finished product generator. Used with that mindset, it reduces the time spent on routine scripting patterns and frees developer capacity for the complex, context-specific work that AI cannot do without deep knowledge of your specific implementation.