Mastering ServiceNow Catalog Client Scripts: Your Top 10 Interview Questions Answered
The ServiceNow Service Catalog is the gateway to a streamlined IT service delivery. At its heart, Catalog Client Scripts are the unsung heroes, dynamically enhancing the user experience by manipulating fields, validating data, and providing real-time feedback directly within the catalog item form. For any aspiring ServiceNow developer or administrator, a solid understanding of these scripts is paramount. In this comprehensive guide, we’ll delve into the top 10 interview questions you’re likely to encounter, providing practical, human-like explanations, real-world examples, and valuable tips to help you ace your next interview.
Interview Relevance:
Interviewers want to gauge your practical experience with client-side scripting in the context of the Service Catalog. They’re looking for your ability to:
- Understand the core functionalities of client scripts.
- Write efficient and effective JavaScript for the catalog.
- Troubleshoot common issues.
- Follow best practices for maintainability and performance.
Human Touch: Be honest and specific. If you’re not on the absolute latest, mention the most recent stable version you’re comfortable with. The key is to demonstrate awareness of the platform’s evolution.
Troubleshooting Tip: If you’re unsure about your instance’s version, navigate to “System Diagnostics” > “About” in the application navigator. This will show you the exact release information.
Human Touch: This question assesses your experience trajectory and how you’ve adapted to platform changes. Listing out the versions shows progressive involvement.
Interview Relevance: This helps the interviewer understand your depth of experience and whether you’ve kept up with significant platform updates. Mentioning specific features or challenges from earlier versions can be a bonus.
The best practice is to assign roles to groups rather than individual users. This adheres to the principle of ‘least privilege’ and significantly simplifies user management. When an employee joins or leaves an organization, you simply add or remove them from the relevant groups, and their access rights are automatically updated. This prevents orphaned roles and ensures consistent security policies.”
Real-world Example: Imagine a group called ‘IT Service Desk Agents’. You assign the ‘itil’ role to this group. Any user added to the ‘IT Service Desk Agents’ group automatically gains the ‘itil’ role, allowing them to manage incidents without manually assigning the role to each individual agent.
Troubleshooting Tip: If a user isn’t getting the expected permissions, first check their user record to see their assigned groups. Then, check the roles assigned to those groups. Use the “Roles” related list on the group record and the “Groups” related list on the user record.
sys_user.”Interview Relevance: This is a foundational question to ensure you know the basic table structures you’ll be interacting with, especially in scripting.
sys_user_group_member.”Human Touch: This table is crucial for managing group memberships and understanding relationships between users and groups.
GlideRecord operation on the sys_user table. Here’s a typical example:
var userGr = new GlideRecord('sys_user');
userGr.initialize(); // Prepare a new record
userGr.username = 'jdoe';
userGr.firstname = 'John';
userGr.lastName = 'Doe';
userGr.email = 'jdoe@example.com';
userGr.password = gs.generatePassword(); // Optional: Generate a secure password
userGr.insert(); // Commit the new record to the database
Explanation:
new GlideRecord('sys_user'): Initiates a GlideRecord object to interact with the user table.initialize(): Clears any existing data and prepares the GlideRecord for a new record insertion.- Setting fields like
username,firstname,lastName,email: Populates the required fields for the new user. insert(): Saves the new user record to thesys_usertable.
Troubleshooting Tip: Always check for duplicate usernames or emails before inserting to avoid errors. You can use userGr.get('username', 'jdoe') to check for existence.
GlideRecord on the sys_user_group table:
var newGr = new GlideRecord('sys_user_group');
newGr.initialize(); // Prepare for a new group
newGr.name = 'Service Catalog Admins';
newGr.manager = '62826bf03710200044e0bfc8bcbe5df1'; // sys_id of the manager
newGr.email = 'catalog.admins@example.com';
newGr.description = 'Group for managing Service Catalog items';
newGr.insert(); // Save the new group
Explanation:
new GlideRecord('sys_user_group'): Targets the group table.initialize(): Sets up for a new record.- Setting fields like
name,manager(using the manager’s sys_id),email, anddescription. insert(): Creates the group record.
Interview Relevance: This demonstrates your understanding of administrative scripting tasks, which are common in ServiceNow implementations.
To add a role to a user: You interact with the sys_user_has_role table.
var userRole = new GlideRecord('sys_user_has_role');
userRole.setValue('user', 'sys_id_of_the_user'); // sys_id of the user
userRole.setValue('role', 'sys_id_of_the_role'); // sys_id of the role
userRole.insert();
To add a role to a group: You interact with the sys_group_has_role table.
var grpRole = new GlideRecord('sys_group_has_role');
grpRole.setValue('group', 'sys_id_of_the_group'); // sys_id of the group
grpRole.setValue('role', 'sys_id_of_the_role'); // sys_id of the role
grpRole.insert();
Explanation:
sys_user_has_role: This table creates a link between a user and a role.sys_group_has_role: This table links a group to a role.- You need the
sys_idof both the user/group and the role you’re assigning. You can find role sys_ids in thesys_roletable.
Troubleshooting Tip: Always ensure the user/group and role records actually exist before attempting to create the link. Check for existing entries to avoid duplicates.
Real-world Example: Think of a manager who needs to approve requests. If the manager goes on vacation, they can delegate their approval tasks to a senior team member. This ensures that critical approvals aren’t delayed.
In ServiceNow, this is configured on the original user’s record. You’d go to their user form, scroll down to the ‘Delegates’ related list, and specify the delegate (who is doing the work), the start and end dates of the delegation, and what specific tasks or permissions the delegate can handle (e.g., approvals, notifications).”
Interview Relevance: This question tests your understanding of user management and process continuity features within ServiceNow, which are crucial for operational efficiency.
sys_user_group_member table.To add a group member:
var grMem = new GlideRecord('sys_user_group_member');
grMem.user = 'sys_id_of_the_user'; // The user to add
grMem.group = 'sys_id_of_the_group'; // The group to add them to
grMem.insert();
To remove a group member:
var grMem = new GlideRecord('sys_user_group_member');
grMem.addQuery('user', 'sys_id_of_the_user'); // The user to remove
grMem.addQuery('group', 'sys_id_of_the_group'); // The group to remove them from
grMem.query(); // Execute the query to find the membership record
if (grMem.next()) { // If a matching record is found
grMem.deleteRecord(); // Remove the membership
}
Explanation:
- For adding, you simply create a new record in
sys_user_group_memberlinking the user and group. - For removing, you first query the table to find the specific membership record using both the user and group
sys_ids and then delete that record.
Troubleshooting Tip: When removing, ensure your query is specific enough. If a user is in multiple groups, querying only by user might attempt to delete incorrect memberships. Always query by both user and group.
g_user. To get the current user’s sys_id, you would use:
var currentUserId = g_user.userID;
console.log('Current User ID:', currentUserId);
Human Touch: This is a very common piece of scripting you’ll use to personalize catalog experiences or check user-specific conditions. g_user.userID is universally available in client scripts.
Interview Relevance: This demonstrates your understanding of client-side context objects, essential for making dynamic changes within the user interface.
gs (GlideSystem) object. The method to get the current user’s sys_id is:
var currentUserId = gs.getUserID();
gs.info('Current User ID: ' + currentUserId);
Explanation:
gs.getUserID(): Retrieves thesys_idof the user currently logged in or whose session is being processed.
Troubleshooting Tip: Be mindful of context. In some background scripts or scheduled jobs, there might not be an explicit ‘logged-in’ user. gs.getUserID() will return an empty string or a system user’s ID in such cases. Always test in the intended execution context.
gs.getUser() object provides a handy method for this:
// Check if the current user is a member of the 'ITIL Users' group
var isMember = gs.getUser().isMemberOf('ITIL Users'); // Provide the group name
if (isMember) {
gs.info('The current user is a member of the specified group.');
} else {
gs.info('The current user is NOT a member of the specified group.');
}
Explanation:
gs.getUser(): Gets the user object for the current user.isMemberOf('group name'): Returnstrueif the user is a member of the group whosenamematches the provided string, andfalseotherwise.
Human Touch: This is a staple for controlling access to features or customizing catalog item behavior based on user roles and group affiliations. For example, showing or hiding a specific catalog item for certain teams.
Troubleshooting Tip: Ensure you’re using the exact, case-sensitive name of the group. If the group name changes, your script will break. It’s often safer to query by group sys_id if possible, especially in more complex scenarios.
security_admin role. This role has elevated privileges specifically for managing security rules across the platform.”Interview Relevance: Understanding security roles is critical for any ServiceNow administrator or developer. It shows you know how to control access to sensitive configurations.
Human Touch: You can impersonate a user by going to the user menu (top right, usually your profile picture) and selecting ‘Impersonate User’.
Troubleshooting Tip: Always remember to stop impersonating once you’re done testing! Leaving yourself impersonating another user can lead to unintended data modifications or confusion.
Examples:
- Display density (Compact, Comfortable, Cozy)
- Date/time formats
- List column layouts
- Email notification settings
When a user changes a preference, it’s stored in the sys_user_preference table, associated with their user record. This ensures that their customized view is retained across sessions.”
Interview Relevance: Understanding user preferences shows you grasp how ServiceNow caters to individual user needs and how these preferences can sometimes influence the behavior of scripts or UI policies (though direct manipulation of preferences is less common in catalog scripts, understanding their existence is key).
Real-world Example: Your email is not sending, your laptop won’t boot, or the company printer is offline. These are all classic examples of incidents.
Interview Relevance: While this isn’t directly a *catalog client script* question, understanding the core ITIL processes that ServiceNow supports is crucial. Catalog items often trigger incidents.
Real-world Example: If multiple employees report that a specific application crashes every Tuesday morning, that recurring issue would be investigated as a problem to find the root cause and fix it permanently.
Relationship to Incidents: Often, multiple incidents can be linked to a single problem record. Closing the problem record (once the root cause is fixed) helps in closing all associated incidents or at least provides a permanent solution.
Interview Relevance: This shows you understand the interconnectedness of IT Service Management processes within ServiceNow.
Interview Relevance: Demonstrates understanding of the SDLC and how incidents can drive proactive changes.
GlideRecord on the incident table. Here’s an example:
var gr = new GlideRecord('incident');
gr.initialize(); // Prepare for a new incident
gr.caller_id = 'sys_id_of_the_caller'; // e.g., gs.getUserID()
gr.category = 'inquiry';
gr.subcategory = 'antivirus';
gr.cmdb_ci = 'sys_id_of_the_configuration_item'; // Optional: link to a CI
gr.short_description = 'User reporting slow system performance';
gr.description = 'The user is experiencing significant slowdowns, impacting productivity. Please investigate.';
gr.assignment_group = 'sys_id_of_the_assignment_group'; // Optional: assign to a group
gr.insert(); // Save the incident
Explanation:
new GlideRecord('incident'): Targets the incident table.initialize(): Prepares for a new record.- Populating fields like
caller_id(who reported it),category,subcategory,cmdb_ci(the affected configuration item),short_description,description, andassignment_group. insert(): Creates the incident.
Interview Relevance: This is a common task for automation or integrating external systems with ServiceNow. It shows you can create core ITSM records via scripting.
Troubleshooting Tip: Ensure that the sys_ids you use for fields like caller_id, cmdb_ci, and assignment_group are valid and refer to existing records. Incorrect sys_ids will cause the insert to fail or create orphaned records.
GlideRecord on the problem table:
var gr = new GlideRecord('problem');
gr.initialize(); // Prepare for a new problem
gr.caller_id = 'sys_id_of_the_reporter'; // e.g., gs.getUserID()
gr.category = 'application';
gr.subcategory = 'database';
gr.cmdb_ci = 'sys_id_of_the_affected_ci'; // e.g., the database server
gr.short_description = 'Recurring application errors impacting users';
gr.description = 'Multiple incidents have been raised regarding intermittent application errors. Investigating root cause.';
gr.assignment_group = 'sys_id_of_problem_management_group'; // e.g., Problem Management
gr.insert(); // Save the problem
Explanation: The structure is very similar to incident creation, but you target the problem table and use fields relevant to problem management, such as linking to related incidents if applicable (though not shown in this basic example).
Troubleshooting Tip: When creating problems from incidents, consider if you need to establish the link (e.g., using the problem_id field on the incident). This ensures proper traceability.
GlideRecord pattern, targeting the change_request table:
var gr = new GlideRecord('change_request');
gr.initialize(); // Prepare for a new change request
gr.category = 'standard'; // Or 'normal', 'emergency'
gr.type = 'implementation'; // e.g., implementation, uninstall, upgrade
gr.cmdb_ci = 'sys_id_of_the_affected_ci'; // e.g., the server to be patched
gr.short_description = 'Apply security patch to web servers';
gr.description = 'Applying critical security patch KB12345 to all web servers in production.';
gr.assignment_group = 'sys_id_of_change_management_group'; // e.g., Change Management
gr.insert(); // Save the change request
Explanation: You’ll populate fields like category, type, cmdb_ci, short_description, and assign it to the appropriate group. Note that change management often involves complex workflows, so you might need to set additional fields based on your organization’s change policies.
Troubleshooting Tip: Change requests have many mandatory fields and complex approval workflows. A simple script might create the change, but it won’t necessarily pass through all stages. You’ll need to understand the specific change process and set the appropriate fields accordingly.
incident table.
// Business Rule: Auto-Close Child Incidents
// Table: Incident
// When: after
// Update: true
// Condition: current.state.changesTo(7) && current.parent == ''
// Script:
(function executeRule(current, previous /*null when async*/) {
// Check if the current incident is a parent (no parent field set) and its state is closing
if (current.state == 7 && current.parent == '') { // Assuming state 7 is 'Closed'
gs.info('Parent incident ' + current.number + ' is closing. Closing associated child incidents.');
// GlideRecord to find all child incidents associated with this parent
var grChild = new GlideRecord('incident');
grChild.addQuery('parent', current.sys_id); // Filter by the parent's sys_id
grChild.query();
while (grChild.next()) {
// Only update if the child incident is not already closed
if (grChild.state != 7) {
grChild.state = 7; // Set the state to Closed
grChild.update(); // Update the child incident record
gs.info('Closed child incident: ' + grChild.number);
}
}
}
})(current, previous);
Explanation:
- Table:
incident. - When:
after– We want this to run after the parent incident has been saved with the ‘Closed’ state. - Update:
true– This rule should trigger when an existing incident record is updated. - Condition:
current.state.changesTo(7) && current.parent == ''– This ensures the rule only fires when the state is changed to 7 (Closed) AND the incident itself is a parent (i.e., itsparentfield is empty). - Script: It queries for all incidents where the
parentfield matches thesys_idof the current parent incident. For each found child, it sets its state to 7 (Closed) and updates it.
Troubleshooting Tip: Make sure you have the correct state value for ‘Closed’. You can find this by right-clicking the state field label on an incident and selecting “Configure Dictionary”. Also, ensure the parent field on child incidents is correctly populated.
incident table to prevent closure if associated tasks are open.
// Business Rule: Prevent Incident Closure if Tasks are Open
// Table: Incident
// When: before
// Insert: false
// Update: true
// Condition: current.state.changesTo(3) // Assuming state 3 is 'Closed'
// Script:
(function executeRule(current, previous /*null when async*/) {
// Check if the incident is being closed
if (current.state == 3) { // Assuming state 3 is 'Closed'
// GlideRecord to find open incident tasks associated with this incident
var grTask = new GlideRecord('incident_task');
grTask.addQuery('incident', current.sys_id); // Link to the current incident
grTask.addQuery('state', '!=', 3); // Assuming state 3 is 'Closed' for tasks
grTask.query();
if (grTask.hasNext()) { // If there are any open tasks
gs.addErrorMessage('Cannot close the incident because there are open incident tasks. Please close all associated tasks first.');
current.setAbortAction(true); // Stop the update operation
}
}
})(current, previous);
Explanation:
- Table:
incident. - When:
before– This rule must run before the incident is saved as ‘Closed’ to prevent it. - Condition:
current.state.changesTo(3)– Triggers when the state is about to change to ‘Closed’. - Script: It queries the
incident_tasktable, looking for tasks linked to the current incident that are NOT in a ‘Closed’ state. If any are found, it displays an error message and usescurrent.setAbortAction(true)to stop the incident from being closed.
Adaptation for Problem/Change: You would create similar ‘Before’ Business Rules on the problem and change_request tables, querying their respective task tables (e.g., problem_task, change_task) and applying the same logic.
Troubleshooting Tip: Ensure the state values for ‘Closed’ are correct for both incidents and their respective tasks. Mismatched states are a common pitfall. Also, verify the link between incidents and tasks (e.g., the incident field on incident_task).
problem table.
// Business Rule: Auto-Close Incidents on Problem Closure
// Table: Problem
// When: after
// Update: true
// Condition: current.state.changesTo(7) // Assuming state 7 is 'Closed'
// Script:
(function executeRule(current, previous /*null when async*/) {
// Check if the problem is being closed
if (current.state == 7) { // Assuming state 7 is 'Closed'
gs.info('Problem ' + current.number + ' is closing. Closing associated incidents.');
// GlideRecord to find incidents associated with this problem
var grIncident = new GlideRecord('incident');
grIncident.addQuery('problem_id', current.sys_id); // Link to the problem's sys_id
grIncident.addQuery('state', '!=', 7); // Only update incidents that are not already closed
grIncident.query();
while (grIncident.next()) {
grIncident.state = 7; // Set the incident state to Closed
grIncident.update(); // Update the incident record
gs.info('Closed incident: ' + grIncident.number);
}
}
})(current, previous);
Explanation:
- Table:
problem. - When:
after– After the problem is saved as ‘Closed’. - Update:
true– For updates to existing records. - Condition:
current.state.changesTo(7)– Fires when the state changes to ‘Closed’. - Script: It queries the
incidenttable for incidents where theproblem_idmatches the current problem’ssys_id. For any open incidents linked to this problem, it sets their state to ‘Closed’ and updates them.
Troubleshooting Tip: Confirm the correct state value for ‘Closed’ for both problems and incidents. Ensure the problem_id field on the incident table is correctly populated when a problem is linked.
- Incident: The primary goal is to restore service as quickly as possible. When something breaks for a user, they raise an incident. It’s reactive and focused on immediate resolution.
- Problem: Deals with the root cause of incidents. If multiple incidents have similar symptoms, or a single incident indicates a deeper systemic issue, a problem record is created to investigate and find a permanent fix, thereby preventing future incidents. It’s proactive and aims for long-term stability.
- Change: Manages the implementation of changes to the IT environment. This could be a fix for a problem, an upgrade, a new deployment, or a configuration adjustment. The goal is to implement changes smoothly, with minimal disruption, and often, a change request is triggered by a problem resolution or even an incident workaround that needs to become permanent.
In essence:
- A user reports an Incident.
- If the incident is recurring or points to a systemic issue, a Problem is identified to find the root cause.
- Resolving the Problem often requires a controlled modification to the IT environment, leading to the creation of a Change Request.
- The successful completion of the Change resolves the underlying Problem, thus preventing future Incidents.
”
Interview Relevance: This shows you understand how ServiceNow supports core ITIL processes and how these processes integrate. It’s a broad question that demonstrates your grasp of the platform’s purpose beyond just scripting.
x_ or u_. Some very common ones include:incidentproblemchange_requestsc_req_item(Requested Item)sc_cat_item(Catalog Item)sys_user(User)sys_group(Group)task(Base table for tasks)cmdb_ci(Base table for Configuration Items)sys_audit(Audit history)
”
Interview Relevance: Demonstrates familiarity with the core data model of ServiceNow.
task: This is the parent table for many task-based records like Incidents, Problems, Change Requests, and Service Catalog Tasks. It provides common fields like state, assignment group, assigned to, short description, etc.cmdb_ci: The base table for Configuration Items. All items within your Configuration Management Database (CMDB) extend from this table, providing common attributes for managing IT assets and services.cmdb: The top-level CMDB table, from whichcmdb_ciand its various categories extend.sys_security_acl: The base table for Access Control Lists.
”
Explanation: When you extend a table, you inherit all its fields. This promotes reusability and consistency across the platform.
task table is the parent. Some common tables that extend from task are:incidentproblemchange_requestsc_task(Service Catalog Task)std_change_proposal(Standard Change Proposal)knowledge(though it extends fromcmms_model, it can sometimes be associated with task-like workflows)
”
Interview Relevance: Shows understanding of the table hierarchy and how it supports efficient data management.
- A create ACL
- A delete ACL
- A read ACL
- An write ACL
If you uncheck that option during table creation, these default ACLs will not be generated.”
Interview Relevance: This question tests your knowledge of table creation best practices and security defaults.
Troubleshooting Tip: If you need to secure a table more granularly, you can always create additional ACLs after the initial table creation, or manually remove and redefine the default ones.
INC0012345, you configure it in the Dictionary Entry for that field. When defining the field’s properties:- Go to the Control tab in the Dictionary Entry.
- Check the Auto Number checkbox.
- You’ll then define the Prefix (e.g.,
INC) and the Number of digits (e.g.,7for 7 digits after the prefix).
ServiceNow then handles the incrementing and formatting automatically. For existing tables like Incident, this is already configured.”
Interview Relevance: This shows you know how to implement standard ServiceNow features for record identification and tracking.
Here’s what happens:
- Inheritance: All fields from the parent table are automatically available in the child table. You don’t need to recreate them.
- No New Sys Fields: Standard system fields (like
sys_created_on,sys_updated_on,sys_id,sys_mod_count) are NOT recreated in the child table. They reside in the parent and are inherited. ClassField: A field calledclassis created on the parent table. This field stores thesys_idof the actual table record that the current row belongs to. This is how ServiceNow knows whether a record in thetasktable is actually anincident, aproblem, or achange_request.- Single
ClassField: Even if a table extends multiple other tables (though direct extension is typically one level, the concept of a ‘class’ points to its ultimate origin), it will only have oneclassfield in its hierarchy.
”
Real-world Example: The incident table extends the task table. So, an incident has all the fields of a task (like caller, short description, state) plus its own specific fields (like impact, urgency, priority).
Interview Relevance: This demonstrates an understanding of ServiceNow’s object-oriented database model and how it facilitates platform extensibility.
- String: For short text entries.
- Reference: Links to another record in a different table (e.g., linking an incident to a user).
- Choice: A dropdown list of predefined options.
- Date: For selecting a date.
- Date/Time: For selecting a date and time.
- Boolean: A true/false or checkbox field.
- Integer: For whole numbers.
- Decimal: For numbers with decimal places.
- URL: For web links.
- Email: Specifically formatted for email addresses.
- (Bonus!) List: Allows selecting multiple records from another table.
- (Bonus!) Journal: For free-form text entries with history, like work notes.
”
Interview Relevance: This shows you’re familiar with the fundamental building blocks of tables and forms in ServiceNow.
- Normal Tables (e.g.,
incident,sys_user): These tables store data permanently. Records are created and remain in the table until they are explicitly deleted or archived according to retention policies. They are used for ongoing operational data. - Temporary Tables (e.g.,
import_set_row,ecc_agent_heartbeat): These tables are designed to hold data for a limited period. They often extend thesys_import_set_rowtable (or similar) and are typically used for staging data during import processes, for short-term logging, or for caching transient information. Data in these tables is usually automatically purged after a predefined retention period (often around 7 days, but configurable).
”
Interview Relevance: Understanding data storage and lifecycle management is important for database design and performance tuning.
Interview Relevance: Shows you understand data lifecycle management and archival strategies in ServiceNow.
- Normal Tables (e.g.,
incident,sys_user): These tables store data directly within your ServiceNow instance’s database. When you query these tables, you’re retrieving data that is physically located and managed by your ServiceNow instance. - Remote Tables (often accessed via REST/SOAP integrations or specific configurations like Data Sources for ETL): This refers to tables or data sources that reside outside of your ServiceNow instance. When you query or interact with a ‘remote table’ within ServiceNow, you are typically making a call to an external system to retrieve or process data in real-time. ServiceNow acts as an intermediary or a client to this external data.
”
Real-world Example: A normal table is your ServiceNow incident list. A remote table might be querying a customer’s ERP system for order status via a ServiceNow integration.
Interview Relevance: This question probes your understanding of data integration and ServiceNow’s ability to interact with external systems.
- One-to-Many Relationship: This is the most common type. It means one record in Table A can be related to multiple records in Table B, but each record in Table B is related to only one record in Table A.
Example: AUser(Table A) can have manyIncidents(Table B). Each incident is assigned to one user, but a user can be assigned many incidents. TheUserfield on theincidenttable is a reference to thesys_usertable. - Many-to-Many Relationship: This is a more complex relationship where one record in Table A can relate to multiple records in Table B, AND one record in Table B can relate to multiple records in Table A. These are typically implemented using an intermediary table.
Example:IncidentsandGroups. An incident might be assigned to multiple groups for different types of work, and a single group (e.g., Network Team) can be assigned many incidents. Thesys_user_group_membertable is a classic example of enabling many-to-many between users and groups. - One-to-One Relationship: Less common, where one record in Table A is related to exactly one record in Table B, and vice versa. This might be used for specific extensions where a child table has a unique, singular relationship to its parent or another related record. For instance, some specialized configuration might have a one-to-one link.
”
Interview Relevance: Understanding relationships is key to designing effective data models and building robust integrations.
- Forms: The standard graphical user interface where users manually fill in fields and click ‘Submit’ or ‘Save’.
- Record Producers: A catalog item type that creates a record in a table when submitted, often mapping catalog variables to table fields. This is very common for Service Catalog requests.
- GlideRecord (Scripting): Using JavaScript’s
GlideRecordAPI in Business Rules, Client Scripts, Script Includes, etc., to programmatically create records. - Email: ServiceNow can be configured to automatically create records (like incidents or tickets) from incoming emails.
- Import Sets / Data Import: Using features like ‘Load Data’ or scheduled imports to bulk create records from files (CSV, Excel, XML) or external data sources.
- REST API / SOAP Web Services: Creating records from external applications by sending data to ServiceNow’s web service endpoints.
- Scheduled Jobs: Scripts that run on a schedule can create records as part of automated processes.
”
Interview Relevance: Shows breadth of knowledge on how data gets into ServiceNow.
Client-Side (UI):
- Dictionary Properties: You can set a field as ‘Mandatory’ or ‘Read only’ directly on the field’s Dictionary Entry. This is a baseline setting.
- UI Policies: These are powerful client-side scripts that can dynamically change a field’s visibility (show/hide), make it mandatory/optional, or set it as read-only/editable based on conditions evaluated on the form.
- Client Scripts (
g_form): Using JavaScript functions likeg_form.setMandatory(),g_form.setReadOnly(), andg_form.setVisible()directly within client scripts (e.g., OnLoad, OnChange).
Server-Side (Data Enforcement):
- Dictionary Overrides: Similar to dictionary properties but allows you to override parent table field attributes in a child table.
- Data Policies: These provide server-side (and client-side rendering) enforcement of mandatory and read-only attributes, similar to UI Policies but enforced at the data layer, meaning they apply regardless of how the record is accessed (UI, API, Import).
- Business Rules: You can use server-side scripts in Business Rules to set field values or make them read-only under specific conditions before a record is saved.
- Access Control Lists (ACLs): While primarily for read/write access to records and fields, ACLs can effectively make fields read-only by denying write access.
”
Interview Relevance: This is a fundamental question about UI and data control, crucial for building secure and user-friendly applications.
Why only one? If multiple fields were marked as ‘Display’, ServiceNow wouldn’t know which one to prioritize. This would lead to unpredictable behavior, confusion in displaying records in reference lookups, and potential issues with search functionality.
Best Practice: Typically, a unique identifier like ‘Name’ or ‘Number’ is chosen as the display field. For example, on the sys_user table, the name field is marked as display. On the incident table, number is the display field.
”
Interview Relevance: This tests your understanding of database design principles and ServiceNow’s specific limitations and best practices.
sys_db_object. This table holds information about every table defined on the platform, including its name, label, columns, attributes, and other schema-related details. When you create a new table or modify an existing one, you are essentially creating or modifying records within sys_db_object and its related tables.”Interview Relevance: Shows you understand the underlying meta-data management of the ServiceNow platform.
- Dictionary Entry: The most straightforward method is to set a default value directly in the field’s Dictionary Entry. There’s a ‘Default value’ field where you can enter a static value. This value will be pre-populated whenever a new record of that table is created.
- OnLoad Client Script: For dynamic default values that depend on other fields or the current user, you can use an OnLoad Client Script. Using
g_form.setDefaultValue('field_name', value);, you can set a default value when the form loads. - Dictionary Overrides: If you’re extending a table and want to set a default value for a field that differs from the parent table’s default, you can use a Dictionary Override.
- Business Rules (onInsert): For server-side defaults that are more complex or depend on other server-side logic, you can use an ‘After’ or ‘Before’ Business Rule that runs on insert, setting the default value using
current.setValue('field_name', value);.
”
Interview Relevance: This is a common requirement for improving user experience and ensuring data consistency.
Real-world Example: Setting the ‘State’ field to ‘New’ by default on incident creation, or setting the ‘Caller’ field to the currently logged-in user via an OnLoad Client Script.
current object is a special variable available in server-side scripting environments like Business Rules and Fix Scripts. It represents the record being processed at that moment.- On Insert: When a new record is inserted,
currentrefers to the record being created. - On Update: When an existing record is updated,
currentrefers to the record with its newly modified values. - On Delete: When a record is deleted,
currentrefers to the record that is about to be deleted.
You use the current object to get and set values of fields on the record in context. For example, current.setValue('short_description', 'New value');.”
Interview Relevance: Essential for server-side scripting. It’s the gateway to manipulating the record you’re working on.
current object with methods like setValue() and setDisplayValue().current.setValue('field_name', value);: This is the standard method to set a field’s value. For reference fields, you must provide thesys_idof the referenced record. For choice lists, you provide the actual choice value. For strings, numbers, dates, etc., you provide the corresponding data type.// Setting a string field current.setValue('short_description', 'Updated description'); // Setting a reference field (e.g., Caller) current.setValue('caller_id', 'sys_id_of_the_user');current.setDisplayValue('field_name', value);: This method is particularly useful for reference fields. Instead of providing thesys_id, you provide the display value (e.g., the user’s name). ServiceNow will attempt to find the correctsys_idbased on this display value. It can also work for choice lists.// Setting a reference field using display value current.setDisplayValue('caller_id', 'Abel Tuter');
”
Interview Relevance: Crucial for understanding how to manipulate data server-side, a fundamental skill.
Troubleshooting Tip: When using setValue for reference fields, if you get an error or the field remains blank, double-check that you have the correct sys_id. If using setDisplayValue and it doesn’t work, ensure the display value you are providing exactly matches an existing record’s display value (case-sensitive sometimes) and that it’s not ambiguous.
There are three main types of Reference Qualifiers:
1. Simple Reference Qualifier
Description: This is the most basic form. You define a static query using field names and operators (=, !=, >, <, STARTSWITH, ENDSWITH, CONTAINS, IN, etc.) directly in the reference qualifier field. It filters records based on predefined conditions.
Example: On an Incident form, for a ‘Configuration Item’ reference field, you might want to show only ‘Active’ CIs. The simple reference qualifier would be: active=true.
How to Use: Navigate to the Dictionary Entry of the reference field. In the ‘Reference qualifier’ field, select ‘Simple’ and enter your query.
2. Dynamic Reference Qualifier
Description: This type uses a ‘Dynamic Filter Option’ which is a reusable query definition. This allows for more flexibility and consistency across different fields. Dynamic filter options can be created by administrators and then selected in the reference qualifier, providing a way to manage complex filtering logic centrally.
Example: Suppose you want to show only users from the same country as the caller of an incident. You could create a dynamic filter option that defines this logic, and then use it as a dynamic reference qualifier for a ‘User’ reference field.
How to Use:
- Go to System Definition > Dynamic Filter Options.
- Create a new dynamic filter option, defining your query logic.
- On the reference field’s Dictionary Entry, select ‘Dynamic’ for the reference qualifier and choose your created dynamic filter option from the dropdown.
3. Advanced Reference Qualifier (JavaScript Reference Qualifier)
Description: This is the most powerful type, allowing you to write custom JavaScript code to dynamically build and apply the query. This is used for very complex filtering logic that cannot be achieved with simple or dynamic qualifiers. The script usually returns a encoded query string. The getRefQual function in a Client Script can also be used for this.
Example: Displaying only ‘Active’ users who are members of a specific group, or users who have a specific role, based on the current form’s context. A script might look like: javascript: 'active=true^sys_idIN' + gs.getUserIDs(); (though this example is very basic, complex ones can involve multiple conditions and lookups).
How to Use: On the reference field’s Dictionary Entry, select ‘Advanced’ for the reference qualifier and enter your JavaScript code that returns an encoded query string.
Differences Explained:
- Simple vs. Dynamic:
- Simple: Static, embedded query. Good for one-off, unchanging filters.
- Dynamic: Reusable query definition managed centrally. Better for consistency and easier maintenance if the same logic is needed in multiple places.
- Dynamic vs. Advanced:
- Dynamic: Uses predefined ‘Dynamic Filter Options’ which are essentially pre-built encoded queries. Less coding, more configuration.
- Advanced: Requires custom JavaScript. Offers ultimate flexibility to build queries on the fly, incorporating complex logic, current form values, or server-side data.
- Simple vs. Advanced:
- Simple: Basic, static filtering. Easy to implement for straightforward needs.
- Advanced: Full JavaScript control. Necessary for highly dynamic or conditional filtering that requires script execution.
”
Interview Relevance: This is a critical question for anyone working with reference fields, which are ubiquitous in ServiceNow. It shows your ability to refine user input and control data relationships.
Troubleshooting Tip: When a reference qualifier isn’t working as expected, check the browser’s JavaScript console for errors. Also, ensure your query syntax is correct. For advanced qualifiers, use gs.info() or gs.log() within your script (if running server-side) to debug the generated query string.
How it works:
- Parent Field: This field has a set of predefined choices.
- Dependent Field: This field also has choices, but these choices are only displayed if they are linked to the currently selected value in the parent field.
Example:
Consider the classic ‘Category’ and ‘Subcategory’ fields on an Incident form.
- Parent Field:
Category(e.g., Hardware, Software, Network) - Dependent Field:
Subcategory(e.g., Laptop, Printer, Operating System, Database, Router)
If a user selects ‘Hardware’ as the Category, the Subcategory dropdown should only show options like ‘Laptop’, ‘Desktop’, ‘Printer’. If they select ‘Software’, it should show options like ‘Operating System’, ‘Application’, ‘Database’.
Configuration:
This is configured within the Dictionary Entry of the dependent field.
- Open the Dictionary Entry for the
Subcategoryfield. - In the Attributes field, add the attribute:
dependent_field=category(replacecategorywith the actual field name of your parent field). - Then, for each choice you create for the
Subcategoryfield, you specify which parent choice it is dependent on.
”
Interview Relevance: Understanding dependent values is key to creating intuitive and user-friendly forms, especially in Service Catalog items where complex options need to be presented logically.
Troubleshooting Tip: Ensure the ‘dependent_field’ attribute in the Dictionary Entry is correctly set to the API name of the parent field. Also, verify that each choice in the dependent field is correctly linked to a choice in the parent field.
When you set a field to ‘Calculated’:
- You provide a JavaScript expression or script that ServiceNow will evaluate.
- The result of this script will be the value stored in the field.
- This calculation can happen on the client-side (e.g., in an OnLoad or OnChange script using
g_form.setValue()) or, more commonly, on the server-side.
Server-Side Calculation Example:
If you have a field ‘Full Name’ on the sys_user table, you could make it a calculated field with a script like:
// Script in Dictionary Entry for 'Full Name' field
var firstName = current.getValue('first_name');
var lastName = current.getValue('last_name');
return firstName + ' ' + lastName;
Whenever the ‘first_name’ or ‘last_name’ fields are updated, the ‘Full Name’ field will automatically re-calculate and display the combined name.
”
Interview Relevance: This demonstrates an understanding of how to automate data population and maintain data integrity through derived values.
Commonly used attributes include:
no_email: Prevents email notifications from being sent for changes to this field. Useful for fields that are updated frequently by system processes.no_attachment: Prevents users from adding attachments to records where this field is present (though this is more typically controlled at the table level or via security rules). The more common use is to disable attachments on a specific form view.readonly: Makes the field read-only. This is functionally similar to setting the field as read-only in the Dictionary, but attributes offer a more flexible way to apply behavior.tree_picker: Transforms a reference field into a tree-like picker interface, useful for hierarchical data like CI classes or locations.dependent_field=parent_field_name: As discussed earlier, used to create cascaded dropdowns.ref_qual_elements=element1,element2: Used in conjunction with reference qualifiers to pass values from other fields on the form into the qualifier’s script or query.max_length=X: Limits the character count for a String field.dynamic_filter_now=true: For date fields, it allows the ‘dynamic’ option to filter based on the current date (e.g., “Last week”).
”
Interview Relevance: Attributes are fundamental for fine-tuning field behavior, and knowing them shows practical experience with the platform’s customization capabilities.
Changes made to this ‘Collection Entry’ (the table’s record in sys_db_object) affect the entire table. For example:
- Setting Attributes on the table definition (like
no_attachmentapplied to the table) would disable attachments for all records in that table. - Checking the Read only checkbox on the table definition would make all fields on that table read-only by default.
- Defining the table’s label, name, and extension.
This entry is automatically created when a table is created and defines the metadata for the entire table. It’s distinct from a field’s dictionary entry, which defines a specific column within the table.”
Interview Relevance: Shows understanding of ServiceNow’s metadata and how table properties are managed.
no_attachment attribute. This is typically done on the Dictionary Entry for the table (the ‘Collection Entry’).Steps:
- Navigate to System Definition > Tables.
- Find and open the Dictionary Entry for your table (e.g.,
incident). - In the Attributes field, add
no_attachment. - Save the record.
This will remove the paperclip icon and the attachments section from the form for that table, effectively disabling attachments for all users on that form.
”
Interview Relevance: Demonstrates practical knowledge of controlling form behavior using attributes.
Use Case: Imagine the Task table has a field ‘Priority’ with default values. If you want the ‘Priority’ field on the Incident table to have different default values, or be mandatory while it’s optional on the parent, you use a dictionary override.
Properties that can be overridden include:
- Default value: Set a different default value for the field.
- Mandatory: Make the field mandatory (or uncheck it to make it optional).
- Read only: Make the field read-only (or uncheck it).
- Maximum length: Change the allowed length for String fields.
- Attributes: Add or remove attributes that apply specifically to this field in the child table.
- Reference Qualifiers: Modify the reference qualifier applied to a reference field.
- Display Value: Although generally not recommended to change the display value setting on an overridden field, it is technically possible.
- Label: Change the display label of the field.
Configuration:
- Navigate to System Definition > Dictionary.
- Find the Dictionary Entry for the field in the parent table.
- Right-click the header and select Dictionary Overrides.
- Click New and select your child table, then specify the overridden properties.
”
Interview Relevance: This is a key concept for extending and customizing ServiceNow tables effectively, showing an understanding of table inheritance and specialization.
When you create a new application or a new module within an existing application, you are defining an Application Menu. For example, under ‘Incident’, you have modules like ‘Open’, ‘All’, ‘Assigned to me’, etc. These are all Application Menus that point to specific reports, lists, or forms.
They are essential for organizing the user interface and providing a structured way for users to interact with ServiceNow data and processes.”
Interview Relevance: Shows understanding of UI navigation and how users access ServiceNow features.
In the context of a form or record, a ‘process flow’ might refer to a visual indicator showing the current stage of that record’s lifecycle. For instance, on an Incident form, you might see a visual representation of stages like ‘New’, ‘In Progress’, ‘On Hold’, ‘Resolved’, ‘Closed’.
Flow Designer is ServiceNow’s modern low-code tool for automating multi-step processes that can involve tasks, approvals, notifications, and integrations, often triggered by specific events.”
Interview Relevance: Demonstrates awareness of process automation and visual workflow tools within ServiceNow.
How they work:
- You define a set of conditions (e.g., if ‘Category’ is ‘Hardware’).
- For each condition, you specify which field’s value in the current record should be used to look up a value in another table.
- Then, you specify which field in the looked-up table contains the value to populate, and which field on the current form should receive that value.
Example:
If a user selects ‘Laptop’ as the Subcategory on an Incident, a data lookup rule might automatically populate the ‘Configuration Item’ field with a default laptop CI, or set a specific assignment group based on the laptop model.
They are typically configured under System UI > Data Lookup Rules.”
Interview Relevance: Shows you know about efficient ways to pre-populate forms and reduce manual data entry.
UI Policies can be used to:
- Make fields mandatory or optional.
- Make fields read-only or editable.
- Make fields visible or hidden.
- Set default values for fields.
- Show or hide related lists on a form.
They are configured using conditions (similar to Business Rules) and UI Policy Actions, which define what happens to specific fields when the conditions are met. They are evaluated when the form loads (‘On Load’) and can also be triggered by changes to other fields (‘On Change’).”
Interview Relevance: This is a cornerstone of ServiceNow form customization. Understanding UI Policies is essential for making forms dynamic and user-friendly.
If you uncheck the ‘Global’ checkbox, you will then be prompted to specify a particular View name. In this case, the UI Policy will only apply to that specific view of the form. This is useful when you have different views of the same form designed for different roles or purposes, and you want distinct UI behaviors for each view.”
Interview Relevance: Shows you understand how to control the scope and application of UI policies across different user interfaces.
Example:
Let’s say you have a UI Policy Action that makes a field ‘Mandatory’ when a certain condition is met.
- If ‘Reverse if false’ is checked: When the condition is true, the field becomes mandatory. When the condition becomes false, the field reverts to its default (optional) state.
- If ‘Reverse if false’ is unchecked: When the condition is true, the field becomes mandatory. However, when the condition becomes false, the field remains mandatory. The original state is not restored automatically.
This is incredibly useful for managing dynamic form states without needing multiple UI Policies or complex Client Scripts for each state change.”
Interview Relevance: This demonstrates an understanding of how to create sophisticated dynamic form behavior efficiently.
- If ‘On Load’ is checked: The UI Policy runs as soon as the form appears in the browser. This is useful for setting initial states, default values, or making fields visible/hidden right away based on initial form data.
- If ‘On Load’ is unchecked: The UI Policy does not run when the form is loaded. Instead, its conditions and actions are only triggered when a specific event occurs on the form, such as a field’s value changing (which would be handled by an ‘On Change’ trigger, or indirectly by a user interaction that then evaluates the conditions).
For most UI Policies that need to set an initial state, ‘On Load’ is typically checked. If a UI Policy is designed to react *only* to user input after the form has loaded, then ‘On Load’ might be unchecked. However, UI Policies are generally evaluated on load by default, so the primary purpose of this checkbox is to ensure it *does* run on load.
Interview Relevance: Understanding when and how UI Policies are executed is key to their effective use.
- If ‘Inherit’ is checked: The UI Policy and its actions will automatically be applied to any tables that extend the current table. For example, if you define a UI Policy on the
tasktable with ‘Inherit’ checked, that UI Policy will also apply toincident,problem,change_request, and any other tables extendingtask. - If ‘Inherit’ is unchecked: The UI Policy will only apply to the table it is defined on. It will not be inherited by child tables.
This is a powerful way to enforce consistent UI behavior across related tables without duplicating logic.
”
Interview Relevance: Demonstrates knowledge of how to manage UI behavior across table hierarchies.
- UI Policy Script: On the main UI Policy form, there are two checkboxes: ‘Run scripts’. If you check this box, it enables two related lists: ‘UI Policy Script’ for OnLoad scripts and ‘UI Policy Script’ for OnChange scripts. These scripts execute server-side or client-side depending on the UI policy’s context.
- UI Policy Actions: Within each UI Policy Action, there’s a ‘Run script’ checkbox. If you check this, you can enter a client-side JavaScript snippet that will execute when that specific UI Policy Action is applied (e.g., when a field is made mandatory, you can run a script to perform additional actions).
The ‘Run scripts’ checkboxes on the main UI Policy form usually enable client-side scripting for the UI Policy itself, affecting how conditions are evaluated or how actions are performed dynamically. When you need to execute scripts based on the conditions of the UI Policy, you would typically enable ‘Run scripts’ and use the UI Policy Scripts related list. For actions that need custom scripting, you’d check ‘Run scripts’ on the action.
”
Interview Relevance: Shows you know how to extend UI Policy functionality with scripting for more complex requirements.
Troubleshooting Tip: If your UI Policy scripts aren’t running, ensure the ‘Run scripts’ checkbox is checked on the UI Policy itself or on the specific UI Policy Action. Also, verify the UI Policy is set to run ‘On Load’ if you expect it to execute immediately upon form load.
How to Convert:
You can typically find a related link or button on the UI Policy form itself that says something like ‘Convert to Data Policy’ or ‘Convert this UI Policy to Data Policies’. Clicking this will create new Data Policies based on the conditions and actions of your UI Policy.”
Interview Relevance: Demonstrates knowledge of platform features that promote code conversion and best practices for data integrity.
- Controlling Data Visibility (Show/Hide): Data Policies primarily enforce data constraints (mandatory, read-only), not field visibility. You cannot directly convert a UI Policy action that hides or shows a field into a Data Policy.
- Controlling Views: UI Policies can sometimes influence which fields are displayed based on view configurations, but Data Policies do not manage view-specific rendering.
- Controlling Related Lists: UI Policies can show or hide related lists on a form, a capability not directly supported by Data Policies.
- Complex Scripting: If a UI Policy relies heavily on complex client-side JavaScript within its scripts or actions (beyond simple mandatory/read-only enforcement), the direct conversion might not capture all the scripting logic accurately or appropriately. Data Policies have server-side script capabilities, but the conversion process is focused on common attributes.
- Dynamic Behavior Based Solely on Client-Side Interaction: While Data Policies have client-side rendering capabilities, the core strength of UI Policies is their direct client-side interaction and immediate feedback. Complex interactive behaviors might be better suited for UI Policies.
In these cases, you would need to re-implement the functionality using Data Policies for server-side enforcement and potentially separate Client Scripts or UI Policies for client-side specific behaviors.
”
Interview Relevance: This shows you understand the limitations of automated tools and the distinct roles of UI Policies and Data Policies.
Data Policies can:
- Make fields mandatory or optional.
- Make fields read-only or editable.
The key distinction is that Data Policies work on the server-side (data layer) and also affect the client-side rendering. This means that whether you create or update a record via the UI, a REST API call, or a scheduled import, the Data Policy’s rules will be enforced. This is different from UI Policies, which primarily operate on the client-side (browser).
Data Policies are configured using conditions, similar to UI Policies, and then define the actions (mandatory, read-only) to be applied to specific fields.”
Interview Relevance: Crucial for understanding how to enforce data governance and integrity in ServiceNow.
Troubleshooting Tip: If a field is mandatory in the UI but isn’t when accessed via an API, it’s likely a Data Policy that needs to be checked or created, rather than just a UI Policy.
Mastering these questions will not only help you ace your ServiceNow interview but also equip you with the foundational knowledge to build robust and user-friendly Service Catalog experiences. Good luck!