Courseiva

CCNA User Interface Development Questions

41 questions · User Interface Development · All types, answers revealed

1
MCQhard

A Service Portal widget is not rendering on the page, and the browser console shows: 'Uncaught ReferenceError: sp is not defined'. The widget's client script uses 'sp.get()'. What is the cause?

A.The widget is placed before the 'sp' provider widget on the page
B.The widget's client controller does not include 'sp' in the dependency list
C.The widget is missing a dependency on 'angular'
D.The server script runs after the client script, causing a race condition
AnswerB

In Service Portal, client controllers must list 'sp' as a dependency to use the sp API.

Why this answer

The user sees an error 'sp is not defined' because the client script uses 'sp.get()' but 'sp' is not available. In Service Portal, the 'sp' API must be explicitly injected into the widget's client controller. If it is not listed in the dependencies of the client controller function, the script will not have access to 'sp'.

Therefore, Option B is correct. Option A is incorrect because the order of widgets on the page does not affect dependency injection for individual widgets. Option C is incorrect because 'angular' is not required for 'sp'; it is the Service Portal API that needs to be injected.

Option D is incorrect because there is no race condition; the server script runs first and does not affect the client-side dependency injection.

2
Multi-Selecthard

Which THREE factors contribute to poor UI performance in ServiceNow forms and portals? (Choose three.)

Select 3 answers
A.Using simple conditions in UI Policies
B.Large number of catalog client scripts in a variable set
C.Multiple client scripts firing on 'load' event
D.Use of CSS custom properties
E.Unindexed GlideRecord queries in UI Macro server scripts
AnswersB, C, E

Variable sets can have many client scripts that execute on load.

Why this answer

Correct options B, C, and E. In ServiceNow, poor UI performance can be caused by excessive client scripts (B), multiple client scripts firing on the 'load' event (C), and unindexed GlideRecord queries in UI Macro server scripts (E). Option A is incorrect because simple conditions in UI Policies are lightweight and do not significantly impact performance.

Option D is incorrect because CSS custom properties are a modern feature that can actually improve performance by reducing repeated styles.

3
MCQhard

A form has a UI Policy that conditionally makes a field mandatory. The UI Policy works on the server side but the mandatory validation is not enforced on the client side before submission. What is the most likely reason?

A.The field's ACL does not allow the user to see it.
B.The UI Policy is set to run only on the server and not on the client.
C.The form is in a different ordering of UI Policies.
D.A client script is overriding the mandatory property.
AnswerB

UI Policies must have the 'Run on client' checkbox enabled to enforce mandatory client-side.

Why this answer

UI Policies that are set to run only on the server will not enforce mandatory validation on the client. For client-side mandatory enforcement, the UI Policy must have the 'Run on client' checkbox checked or the mandatory attribute must be set via a client script. Option A is wrong because ACLs control visibility and access rights, not mandatory field validation.

Option C is wrong because the ordering of UI Policies affects execution order, not whether they run on the client. Option D is wrong because while a client script could override the mandatory property, the issue here is that the UI Policy itself is not set to run on the client, not that it is being overridden.

4
MCQhard

The above Jelly script is used to generate a UI Page. When rendered, the 'cmdb_ci' field does not appear. What is the most likely cause?

A.The Jelly namespace declaration for 'g2' is missing, causing the field to be ignored
B.The <g:ui_field> element must be inside a <g:ui_section> rather than <g:ui_element>
C.The <g:ui_element> containing 'cmdb_ci' is improperly nested inside another <g:ui_element>
D.The 'cmdb_ci' field has a mandatory attribute that conflicts with the UI policy
AnswerC

Invalid nesting causes the parser to drop the inner element.

Why this answer

When a <g:ui_element> is nested inside another <g:ui_element>, the inner element is ignored by the Jelly UI framework. The proper structure requires that <g:ui_element> be placed directly within a <g:ui_section> or <g:ui_form> , not inside another <g:ui_element>. This nesting issue causes the 'cmdb_ci' field not to render.

Option A is incorrect because the namespace is correctly declared if other fields render. Option B is incorrect because a <g:ui_element> does not need to be inside a <g:ui_section> ; it can be directly in a <g:ui_form> . Option D is incorrect because a mandatory attribute does not prevent a field from appearing; it only affects submission behavior.

5
Multi-Selecthard

Which THREE factors can negatively impact the performance of a ServiceNow form?

Select 3 answers
A.Large client script files (e.g., 100KB+).
B.Synchronous Ajax calls in client scripts.
C.A large number of UI Policies on the form.
D.Many tabs (sections) on the form.
E.Use of AngularJS directives in the form.
AnswersA, B, C

Large scripts increase download time and parsing overhead.

Why this answer

Options A, B, and C are correct. Multiple UI Policies increase server load and client-side processing. Synchronous Ajax calls block the UI until they complete.

Large client script files increase download time and parsing. Option D is wrong because the number of tabs does not significantly impact performance. Option E is wrong because AngularJS directives, when used properly, are not a performance issue.

6
MCQhard

A Service Portal widget is not updating data on the page after the user clicks a button that calls a server-side function. The client controller uses $scope.server.get() to call the server. The server script updates a global variable in glideRecord and returns it. However, the widget view does not reflect the change. What is the most likely issue?

A.The widget template is not bound to the correct scope variable.
B.The client controller should use $scope.server.update() instead of $scope.server.get().
C.The client controller is not handling the promise returned by $scope.server.get(); the scope update should be inside the success callback.
D.The server script is not allowed to modify data from a widget server script.
AnswerC

The async call returns a promise; scope must be updated after resolution.

Why this answer

`$scope.server.get()` returns a promise, and the scope variables must be updated inside the `.then()` success callback to ensure the changes are applied after the asynchronous server response is received. Without handling the promise, the client controller executes the next line immediately, and the scope update happens before the server data is available, so the widget view never reflects the change.

Exam trap

ServiceNow often tests the asynchronous nature of `$scope.server.get()` and `$scope.server.post()`, trapping candidates who assume the server call is synchronous or that the scope update happens automatically without handling the promise.

How to eliminate wrong answers

Option A is wrong because the widget template binding is not the issue; the problem is that the scope variable is never updated with the server response, not that it is bound to the wrong variable. Option B is wrong because `$scope.server.update()` is used for server-side updates that modify data, but the question describes a `get()` call that returns data; using `update()` would not fix the asynchronous promise handling issue. Option D is wrong because server scripts in Service Portal widgets are fully allowed to modify data via glideRecord; the restriction is that they cannot use `gs.addErrorMessage()` or `gs.addInfoMessage()` directly, but data modification is permitted.

7
MCQmedium

A developer is designing a custom form in the standard UI (UI16) and needs to add a message that displays only when the 'state' field is 'Closed'. Which feature should be used to achieve this without custom scripting?

A.Create a UI Policy that adds a message when the condition state=Closed is true.
B.Create a form section and set its condition via the 'Conditional' property.
C.Write a Client Script that shows a message when state changes to Closed.
D.Use a UI Macro with a condition that checks the state field.
AnswerA

UI Policies can conditionally display messages without scripting.

Why this answer

UI Policies are the correct declarative feature in UI16 to show a message based on a field value without custom scripting. They run on the client side and can display informational, warning, or error messages when a specified condition (like state=Closed) is met, making option A the appropriate choice.

Exam trap

The trap here is that candidates may confuse UI Policies with Client Scripts, thinking that any client-side behavior requires scripting, when in fact UI Policies provide a no-code alternative for simple conditional actions like showing messages.

How to eliminate wrong answers

Option B is wrong because form sections are used to group fields and can be made conditional via the 'Conditional' property, but they do not display messages; they show or hide entire sections. Option C is wrong because Client Scripts require custom JavaScript code, which the question explicitly says to avoid. Option D is wrong because UI Macros are reusable HTML templates that require scripting to evaluate conditions and are not designed for simple conditional message display without custom code.

8
MCQhard

Refer to the exhibit. A developer wrote this client script to hide a field when another field changes to '1'. However, the script throws a JavaScript error. What is the most likely cause?

A.hideField is not a valid method; the correct method is setDisplay or setVisible.
B.hideField is a server-side method and cannot be used in client scripts.
C.The developer should use showFieldMsg to hide the field.
D.The function signature is incorrect for an onChange client script.
AnswerA

Correct: g_form.setDisplay('field2', false) or g_form.setVisible('field2', false) should be used.

Why this answer

`hideField` is not a valid client-side method in ServiceNow. The correct methods to control field visibility in client scripts are `setDisplay` (to show/hide a field) or `setVisible` (to show/hide a field and its label). Using an undefined method like `hideField` will throw a JavaScript error because the GlideForm (g_form) API does not include it.

Exam trap

ServiceNow often tests the distinction between valid and invalid g_form methods, and the trap here is that candidates may assume `hideField` is a real method because it sounds intuitive, without knowing the exact API names like `setDisplay` or `setVisible`.

How to eliminate wrong answers

Option B is wrong because `hideField` is not a server-side method either; it is simply not a valid method in ServiceNow at all. Option C is wrong because `showFieldMsg` is used to display informational messages on a field, not to hide it. Option D is wrong because the function signature for an onChange client script is `onChange(controlName, oldValue, newValue, isLoading, isTemplate)` — the error is not caused by an incorrect signature but by calling an undefined method.

9
MCQmedium

A developer is asked to add a custom button to the Service Portal form for the 'incident' table. The button should trigger a client script that displays a confirmation dialog before submitting the form. Which approach should the developer use?

A.Create a UI Policy on the incident table with a client script that shows the button conditionally.
B.Create an Access Control Rule (ACL) on the incident table and attach a client script.
C.Create a Business Rule on the incident table that injects a button via server-side code.
D.Create a UI Action on the incident table with a client script and set the 'Show insert' condition.
AnswerD

Correct. UI Actions allow adding custom buttons to forms and attaching client scripts. By setting the 'Show insert' condition appropriately, the button can be displayed on the form and execute a client script that shows a confirmation dialog before submission.

Why this answer

UI Actions in Service Portal are the standard mechanism for adding custom buttons to forms. By creating a UI Action on the incident table with a client script, the developer can add a button that triggers a confirmation dialog before form submission. UI Policies only control field attributes (e.g., visibility, mandatory) and cannot create new UI elements like buttons.

Exam trap

A common mistake is to assume UI Policies can add custom buttons because they control client-side behavior. However, UI Policies only modify existing field properties; they cannot inject new UI elements. UI Actions are specifically designed for adding buttons and attaching client scripts to them.

How to eliminate wrong answers

Option B is wrong because Access Control Rules (ACLs) control data access and security, not UI element visibility or client-side button behavior; attaching a client script to an ACL is not a supported pattern for adding buttons. Option C is wrong because Business Rules run server-side and cannot directly inject buttons into the Service Portal UI; they are used for server-side logic like data validation or automation, not client-side UI manipulation. Option D is wrong because UI Actions in Service Portal are used to add buttons to form headers or lists, but the 'Show insert' condition controls when the button appears based on the form mode (insert vs. update), not for triggering a client-side confirmation dialog before submission; UI Actions with client scripts can show dialogs, but the condition described is irrelevant to the requirement.

10
Multi-Selecteasy

Which TWO of the following are valid types of client scripts in ServiceNow? (Choose two.)

Select 2 answers
A.onDelete
B.onSubmit
C.onChange
D.onClick
E.onUpdate
AnswersB, C

onSubmit client scripts run when the form is submitted.

Why this answer

In ServiceNow, the valid client script types are onChange, onSubmit, onLoad, and onCellEdit. Among the given options, onSubmit (B) and onChange (C) are standard client script types. onDelete, onClick, and onUpdate are not valid client script types in ServiceNow.

11
MCQeasy

A Service Portal widget displays a list of open incidents. The data is updated via a GlideAjax call in the client controller. Users report that the list does not refresh automatically when a new incident is created. The developer wants to implement auto-refresh without manual page reload. The widget is used on a dashboard that does not require real-time updates every second. Which approach is most efficient?

A.Use Angular $interval to call the GlideAjax every 30 seconds in the client controller
B.Set up a real-time data channel using WebSocket and push updates from server
C.Use the 'spNavigation' API to reload the entire page every 30 seconds
D.Trigger the GlideAjax call on mouseover and focus events
AnswerA

Efficient polling mechanism that updates the data without reloading the page.

Why this answer

Using a polling interval (e.g., 30 seconds) strikes a balance between data freshness and server load. Option B is unnecessary since real-time updates are not required. Option C is inefficient due to full page reload.

Option D misses updates when the user is not interacting.

12
MCQmedium

A reference field on a form shows a list of records, but the user cannot see any results when typing. The reference qualifier is set to 'active=true'. What is the most likely cause?

A.The user does not have read access to the referenced table.
B.There are no records that satisfy the reference qualifier condition.
C.The field is read-only and prevents searching.
D.The field's dictionary entry does not have a reference table specified.
AnswerB

A restrictive reference qualifier can result in an empty list.

Why this answer

If the reference qualifier condition 'active=true' filters out all records (e.g., all records are inactive), no results appear. Option A is incorrect: lack of read access would prevent the user from seeing any records at all, but the user can see the field and type. Option C is incorrect: a read-only field prevents editing but does not affect searching for new records.

Option D is incorrect: if no reference table were specified, the field would not function; the problem is the qualifier filtering.

13
MCQmedium

A developer sees the above error in the browser console when an incident form loads. What is the most likely cause?

A.The onLoad client script is running on the server instead of the client.
B.The onLoad client script uses GlideRecord, which is not available client-side.
C.The script uses a typo: 'GlideRecord' should be 'GlideRecord'.
D.GlideRecord has been deprecated and replaced by a newer API.
AnswerB

Client scripts must use GlideAjax to call server-side GlideRecord.

Why this answer

The onLoad client script runs on the client side, where GlideRecord is not available. Using it directly in a client script causes the 'gliderecord is not defined' error. Option A is wrong because server-side scripts can use GlideRecord without error.

Option C is wrong because 'GlideRecord' is spelled correctly. Option D is wrong because GlideRecord is not deprecated.

14
MCQhard

A Service Portal widget is failing to update a reference field on a form after a user selects a value from a reference picker. The developer reviews the widget's client controller and sees the following code snippet: $scope.c.data.selectedItem = value; The server script expects 'selectedItem' to be a sys_id string, but it is receiving an object. What is the most likely cause?

A.The server script expects the parameter in a different scope variable, like $scope.c.data.item.
B.The $scope.c.data assignment is incorrect; it should be $scope.data.
C.The client controller is not allowed to set $scope.c variables.
D.The reference field returns an object with 'value' and 'display' properties; the code should extract the sys_id.
AnswerD

Reference fields return an object; the sys_id is typically in value or sys_id property.

Why this answer

When a reference picker returns a value in Service Portal, it typically provides an object containing both the display value and the sys_id (e.g., {value: 'sys_id', display: 'name'}). The client controller code assigns this entire object to $scope.c.data.selectedItem, but the server script expects a plain sys_id string. The developer must extract the sys_id property (e.g., value.sys_id or value.value) before assigning it to the scope variable.

Exam trap

The trap here is that candidates assume the reference picker returns a simple string (the sys_id) and overlook that Service Portal reference fields return an object with both value and display properties, leading them to choose options about scope naming or assignment syntax instead of the data format mismatch.

How to eliminate wrong answers

Option A is wrong because the issue is not about the scope variable name; the server script correctly expects 'selectedItem', but it receives an object instead of a string. Option B is wrong because $scope.c.data is the correct way to access data in a Service Portal widget's client controller; $scope.data is not used in this context. Option C is wrong because client controllers are fully allowed to set $scope.c variables; this is the standard pattern for passing data to the server script via $scope.c.data.

15
MCQmedium

A ServiceNow developer is tasked with improving the performance of a custom incident form in the classic UI. The form includes a 'category' field that, when changed, triggers an onChange client script. This script uses a GlideRecord query to fetch related data from a large 'cmdb_ci' table (over 100,000 records) and populates a dependent field called 'subcategory' with relevant options. Users report that after selecting a category, the form freezes for 10-15 seconds before the subcategory field updates. The developer needs to maintain real-time updates based on the category selection. What is the best approach to resolve this performance issue while keeping the functionality?

A.Convert the onChange script to a UI Policy with a condition on category and a script action to perform the query.
B.Use a calculated field on the subcategory field that derives its value from a database view.
C.Replace the client script with a Scripted REST API that returns subcategory options, and make an asynchronous AJAX call from the client script to populate the field.
D.Move the query to a Business Rule that runs on 'before' and updates the subcategory field using setValue.
AnswerC

Correct: async AJAX avoids blocking the UI; server handles the heavy query.

Why this answer

It offloads the heavy GlideRecord query from the client to the server via a Scripted REST API, while using an asynchronous AJAX call (e.g., GlideAjax) to avoid blocking the UI thread. This eliminates the 10-15 second freeze by preventing synchronous server-side processing on the client, maintaining real-time updates without freezing the form.

Exam trap

The trap here is that candidates often choose UI Policy (Option A) thinking it can run server-side logic, but UI Policies are purely client-side and cannot execute GlideRecord queries, leading to a misunderstanding of their scope.

How to eliminate wrong answers

Option A is wrong because UI Policies run on the client side and cannot perform GlideRecord queries; they are limited to simple field visibility/readonly conditions and cannot execute server-side database operations. Option B is wrong because calculated fields are evaluated on the server and do not provide real-time client-side updates based on a category change; they are static and cannot dynamically populate a dependent field's choice list. Option D is wrong because a Business Rule runs on the server after the record is saved, not in real-time on the client; it cannot update the subcategory field's options on the form before submission, and it would not resolve the client-side freeze.

16
MCQhard

A Service Portal widget uses AngularJS. The developer needs to share data between the client script and the HTML template. What is the correct approach?

A.Use $rootScope to make data globally available.
B.Use $scope to store data in the client controller.
C.Use the 'c' object (c.data) provided by the widget framework.
D.Create a custom AngularJS factory to manage data.
AnswerC

The 'c' object is the official way to bind data between server and client in widgets.

Why this answer

In ServiceNow portal widgets, the 'c' object serves as the client-side controller context, and data stored in c.data is accessible in both the client script and the HTML template. This is the recommended approach for sharing data within a widget. Option A is wrong because $rootScope makes data global and can lead to unintended side effects.

Option B is wrong because $scope is not directly used in the widget framework; instead, the 'c' object provides the scoped context. Option D is wrong because AngularJS factories are meant for reusable services, not for widget-specific data binding.

17
Multi-Selecteasy

A developer needs to display a warning message to the user when the 'priority' field is changed to '1 - Critical'. Which TWO client-side implementations can achieve this?

Select 2 answers
A.Business Rule with 'when to run' set to 'before' and script to call g_scratchpad.message
B.UI Policy with condition: 'Priority changes' and action script to call g_form.showFieldMsg()
C.onLoad client script that checks the current value of priority and shows a message
D.Data Policy with condition on priority field and message set
E.onChange client script with a condition to check newValue and call g_form.showFieldMsg()
AnswersB, E

Correct: UI Policies can run client-side scripts on field change.

Why this answer

A UI Policy with the condition 'Priority changes' triggers an action script when the priority field is modified, allowing the use of `g_form.showFieldMsg()` to display an inline warning message on the field. Option E is correct because an onChange client script fires when the 'priority' field changes, and within it you can check `newValue` against '1 - Critical' and call `g_form.showFieldMsg()` to show the warning. Both are client-side implementations that respond to field changes without a server round-trip.

Exam trap

The trap here is that candidates confuse server-side implementations (Business Rules, Data Policies) with client-side ones, or mistakenly think an onLoad script can detect a field change that occurs after the form has loaded.

18
MCQmedium

A service portal widget is supposed to load data from a table and display it in a list. The widget renders but shows no data. Which is the most likely cause?

A.The table's ACL denies read access to the user.
B.The widget's client script has a syntax error.
C.The portal page is not configured to include the widget.
D.An error in the widget's server script prevents data from being queried.
AnswerD

The server script is the primary data source; a scripting error would cause no data to be returned.

Why this answer

The widget renders (client-side works) but shows no data, indicating the server-side script that queries the table failed. Option A (ACL denial) would typically show an error or empty data but is less common than a script error. Option B (client script syntax error) would affect interactivity, not initial data load.

Option C (portal page not configured) would prevent the widget from rendering entirely.

19
MCQmedium

A developer wants to customize the appearance of a Service Portal theme. Which approach is recommended to ensure maintainability and scalability?

A.Use LESS variables inside each widget's widget styles
B.Edit the default theme record to change primary colors
C.Define CSS custom properties in the theme's stylesheet and use them throughout widgets
D.Apply inline styles directly in widget templates for fine-grained control
AnswerC

CSS variables are globally available and can be updated in one place, making them ideal for theming.

Why this answer

The recommended approach because CSS custom properties (CSS variables) allow centralized theme management in the theme's stylesheet, making them reusable across all widgets without duplication. This ensures maintainability and scalability. Option A is incorrect because LESS variables defined in widget styles are scoped to that widget and not shared globally, leading to duplication.

Option B is incorrect because editing the default theme record directly can be overwritten during upgrades, causing maintenance issues. Option D is incorrect because inline styles are not scalable, hard to maintain, and cannot be overridden systematically.

20
MCQmedium

A ServiceNow developer has created a custom UI page using the 'UI Page' module. The page is accessible via a direct URL, but when the user navigates to it, the page appears blank with no errors in the browser console. What is the most likely cause?

A.The page references an undeployed client script that fails silently
B.The 'Requires role' ACL restricts the page content from rendering for the user
C.The page is not set as 'Published' in the UI Page configuration
D.The page is using the 'direct' processing type instead of 'producer'
AnswerB

ACL restrictions can cause the page to render blank if the user does not have the required role, and no error will appear in console because the server simply omits content.

Why this answer

A blank UI page without console errors often indicates that the page’s content is suppressed by a security restriction, such as a required role ACL that the user does not have. Since there are no errors, the page is being reached but the content is not rendered. Option A is incorrect because an undeployed client script would cause a client-side script error, not a completely blank page with no console errors.

Option C is incorrect because if the page were not set as ‘Published,’ it would typically show an authorization error rather than a blank page. Option D is incorrect because the processing type (direct vs. producer) affects how the page is called but does not cause a blank page when the page is accessed directly.

21
MCQmedium

A developer is customizing a form layout for the 'incident' table. They want to group related fields into titled sections for better usability. Which approach should they use?

A.Create a UI Page and embed it in the form via an HTML field
B.Add fields to form sections via the Form Layout module
C.Use a catalog client script to rearrange fields dynamically
D.Use a UI Policy to show/hide groups of fields
AnswerB

Form sections allow organizing fields into titled groups on a form.

Why this answer

The Form Layout module in ServiceNow allows administrators to group fields into titled sections on a form, which is the standard way to organize related fields. Option A is incorrect because UI Pages are custom pages that can be embedded via HTML fields, but they are not the standard method for grouping fields. Option C is incorrect because catalog client scripts are used for service catalog forms, not standard incident form layout.

Option D is incorrect because UI Policies control field visibility and behavior based on conditions, but they do not create titled sections for grouping fields.

22
MCQhard

A developer runs this widget server script and expects data.count to be the number of active incidents. However, the widget displays 'undefined' for data.count. What is the most likely cause?

A.The addQuery method syntax is incorrect; it should use a condition string.
B.The while loop uses next(); it should use hasNext() instead.
C.The script is missing the function parameters (options, data) that provide the data object.
D.GlideRecord requires an initialize() call before query.
AnswerC

Without parameters, data is not defined in the closure.

Why this answer

In ServiceNow widget server scripts, the function signature must include the parameters (options, data) to access the data object that is passed to the client script. Without these parameters, the data variable is undefined, causing data.count to display 'undefined'. The script likely defines the function without parameters or with incorrect ones, so the data object is not available.

Exam trap

ServiceNow often tests the requirement for explicit function parameters in widget server scripts, trapping candidates who assume data is globally accessible or who focus on GlideRecord syntax errors instead of the missing parameter signature.

How to eliminate wrong answers

Option A is wrong because the addQuery method syntax is correct as shown; it accepts a field name and value, not a condition string. Option B is wrong because the while loop using next() is valid and does not require hasNext(); hasNext() is used in GlideAggregate, not GlideRecord. Option D is wrong because GlideRecord does not require an initialize() call before query; the new GlideRecord() constructor initializes the object automatically.

23
Multi-Selectmedium

Which TWO client-side APIs are available in a Service Portal widget to interact with form fields?

Select 2 answers
A.spUtil.setValue()
B.c.data (to bind data to the template)
C.g_form.setValue() (to set a field value in a form)
D.g_list.setValue() (to set a value in a list)
E.$scope (to set values in the controller)
AnswersB, C

c.data is the official way to pass data between server and client in widgets.

Why this answer

The correct answers are B and C. In a Service Portal widget, `c.data` is the primary mechanism for data binding between the server and client. `g_form.setValue()` is available when the widget includes a form (e.g., using the Form widget or a custom form). Option A is incorrect because `spUtil.setValue()` does not exist; `spUtil` has methods like `update` and `addInfoMessage`.

Option D is wrong because `g_list.setValue()` is for list views, not standard forms. Option E is incorrect because `$scope` is AngularJS's scope but the recommended pattern in Service Portal is to use `c.data` for data binding.

24
Multi-Selectmedium

A developer needs to create a custom UI page in ServiceNow. Which TWO methods can be used to achieve this? (Choose two.)

Select 2 answers
A.Write a client script that renders HTML dynamically
B.Build a Service Portal widget and embed it in a portal page
C.Define a UI Macro and include it in a form
D.Add a new section to an existing form layout
E.Create a UI Page record in the 'UI Pages' module
AnswersB, E

Service Portal widgets can create pages within a portal context.

Why this answer

The correct answers are B and E. Option E: A UI Page record can be created directly in the 'UI Pages' module, which generates a server-side Jelly script. Option B: Service Portal widgets are a modern approach to building UI components that can be embedded in portal pages, effectively creating custom UI.

Option A is incorrect because client scripts run on the client side and do not create UI pages; they manipulate existing pages. Option C: UI Macros are reusable Jelly snippets, not standalone pages. Option D: Adding a section to an existing form modifies the form layout, not creates a new UI page.

25
MCQhard

A UI Macro on a form is causing slow load times. The macro uses multiple GlideRecord queries in its server-side script. The developer wants to optimize performance without altering functionality. Which action is most effective?

A.Load the macro asynchronously using UI Macro configuration
B.Move the queries to a client script using GlideAjax to reduce server load
C.Use g_form.addOption() to populate a reference field instead of building the macro
D.Replace GlideRecord queries with GlideAggregate and cache the results
AnswerD

GlideAggregate reduces the number of queries by using aggregates, and caching avoids repeated calls, but caching alone may not help if data changes frequently. Actually, using GlideAggregate to combine queries is more effective than caching alone.

Why this answer

Replacing multiple GlideRecord queries with a single GlideAggregate query reduces the number of database calls, improving performance. Caching the results further avoids redundant queries. Option A is incorrect because asynchronous loading does not reduce the total server processing.

Option B is incorrect because moving queries to a client script via GlideAjax only shifts the load but still requires server-side processing. Option C is incorrect because g_form.addOption() is for adding options to a select field, which does not address the macro's performance issue.

26
Multi-Selectmedium

Which TWO of the following are valid ways to customize the Service Portal login page?

Select 2 answers
A.Create a new widget instance on the 'loginpage' widget slot.
B.Override the 'Login' page in the portal record by creating a new page and setting it as the login page.
C.Add a widget option to the login widget to inject custom CSS.
D.Use CSS variables in the portal's theme (SCSS) to style the login page elements.
E.Set the 'login.css' property in sys_properties to a custom stylesheet URL.
AnswersB, D

You can create a custom page and set it as the login page.

Why this answer

The Service Portal login page can be customized by overriding the 'Login' page in the portal record. This is done by creating a new page (e.g., a copy of the default login page) and setting it as the login page in the portal's configuration, which allows full control over the layout and widgets used. Option D is correct because CSS variables defined in the portal's theme (SCSS) can be used to style login page elements, as the theme's SCSS is compiled and applied globally to all portal pages, including the login page.

Exam trap

The trap here is that candidates often confuse widget slots with page types, thinking they can add a widget to a 'loginpage' slot (which does not exist), or they assume system properties can be used to inject custom CSS, when in fact Service Portal relies on theme SCSS and page overrides for login page customization.

27
MCQmedium

A business rule updates a field on the incident table after submission. However, the updated value is not displayed on the form when the record is opened again. What is the most likely cause?

A.The form is not refreshing after submission.
B.The business rule is set to run asynchronously.
C.A client script (onLoad) is setting the field back to its original value.
D.A UI Policy is hiding the field.
AnswerC

Client scripts execute after the form loads and can override server-set values.

Why this answer

A client script (onLoad) can run after the record is opened and set the field back to its original value, overriding the value updated by the business rule. Option A is incorrect because the form does refresh when the record is opened, so the issue is not a lack of refresh. Option B is incorrect: asynchronous business rules still save their updates to the database; the timing of execution does not affect whether the value persists on the form.

Option D is incorrect because hiding a field via UI Policy does not change its value; the value would still be stored.

28
MCQhard

A UI Macro that displays a custom header is not appearing on the form. The macro is referenced in a UI16 theme. What is the first troubleshooting step?

A.Check the browser's HTML source for the macro's placeholder.
B.Ensure the UI Macro is in the global scope.
C.Verify that all referenced UI Scripts are loaded.
D.Examine the UI Macro record for syntax errors in the HTML or Jelly script.
AnswerD

Syntax errors are the primary reason UI Macros fail to render.

Why this answer

The first troubleshooting step is to examine the UI Macro record for syntax errors in the HTML or Jelly script (Option D). Syntax errors are the most common cause of a macro not rendering. Checking the browser's HTML source (A) is possible but not the first step.

Ensuring the UI Macro is in global scope (B) is less likely the issue, as macros are typically accessible within the theme. Verifying UI Scripts (C) is unrelated because UI Scripts are separate client-side resources, not the macro's own code.

29
MCQeasy

Which record type should be used to customize the look and feel of the UI16 interface?

A.UI Script (sys_ui_script)
B.Portal Theme (sp_theme)
C.UI Theme (sys_ui_theme)
D.Branding (sys_brand)
AnswerC

UI Themes define the styling for UI16.

Why this answer

UI Theme (sys_ui_theme). In ServiceNow, the UI16 interface's look and feel is customized using UI Themes, which are stored in the 'sys_ui_theme' table. Option A (UI Script) is incorrect because UI Scripts are used for client-side JavaScript functions, not for theming.

Option B (Portal Theme) is meant for Service Portal configurations, not the UI16 interface. Option D (Branding) handles logos, colors, and fonts but does not provide the full theme customization capabilities of UI Themes.

30
MCQeasy

A UI Policy is used to make a field mandatory when another field has a specific value. The policy is not triggering. What is the first step to troubleshoot?

A.Verify that a script include used in the condition is accessible
B.Ensure the field has a 'Mandatory' attribute on the dictionary
C.Check if the 'Mandatory' ACL on the field prevents modification
D.Review the UI Policy conditions and the order of policies on the form
AnswerD

UI Policies are evaluated in order; a later policy may override the mandatory setting.

Why this answer

When a UI Policy is not triggering, the first step is to review the UI Policy conditions and the order of policies on the form. This ensures the condition is correctly set and not overridden by other policies. Option A is incorrect because script includes are not typically used in UI Policy conditions; UI Policies use simple conditions or scripts that can access script includes, but verifying accessibility is not the first step.

Option B is incorrect because the 'Mandatory' attribute on the dictionary is a different configuration; UI Policy can make a field mandatory irrespective of dictionary attributes. Option C is incorrect because ACLs control access, not mandatory behavior; they do not prevent UI Policy from making a field mandatory.

31
Multi-Selecteasy

Which TWO of the following are valid ways to create a UI Action?

Select 2 answers
A.Duplicate an existing UI Action from the list view.
B.Create a new UI Action record from the UI Actions module.
C.Write a Script Include and configure it as a UI Action.
D.Create a UI Action from the Form Design interface.
E.Create a UI Action from the Business Rules module.
AnswersA, B

Duplicating is a valid method to create a new UI Action.

Why this answer

Options A and B are correct. UI Actions can be created by duplicating an existing UI Action from the list view (Option A) or by creating a new UI Action record directly from the UI Actions module (Option B). Option C is wrong because Script Includes are separate server-side scripts and cannot be configured directly as UI Actions (they might be used in UI Action scripts, but not a direct creation method).

Option D is wrong because the Form Design interface is used for layout customization, not for creating UI Actions. Option E is wrong because the Business Rules module is for business rules, a different record type.

32
MCQeasy

A company wants to hide a field on a catalog item form when a specific variable is selected. What is the most appropriate way to achieve this?

A.Create a UI Policy that hides the field when the condition is met.
B.Modify the form layout to remove the field.
C.Use a catalog client script to hide the field.
D.Write a client script to set the field's display property to false on load.
AnswerA

UI Policies are the standard way to conditionally show/hide fields on forms.

Why this answer

UI Policies are the standard declarative way to control field visibility, read-only, and mandatory states on ServiceNow catalog item forms based on conditions. Option B is incorrect because modifying the form layout only changes the initial arrangement and does not dynamically hide fields. Option C is incorrect because a catalog client script can be used but is less standard and efficient than a UI Policy for visibility control.

Option D is incorrect because a client script setting the display property is not the recommended approach; UI Policy is specifically designed for such conditional logic.

33
MCQeasy

Which of the following is the best practice for referencing a field value in a client script on a ServiceNow form?

A.Using g_l.get('field_name')
B.Using g_form.getValue(document.getElementById('field_name'))
C.Using g_form.getValue('field_name')
D.Using GlideRecord.get() to query the field value
AnswerC

This is the standard client-side API to get the current value of a field on the form.

Why this answer

The correct answer because g_form.getValue('field_name') is the standard client-side API to retrieve the value of a field on a ServiceNow form. Option A is incorrect because g_l.get() is used for GlideAjax calls, not for direct field access. Option B is incorrect because g_form.getValue() does not take a DOM element as an argument; it expects a field name string.

Option D is incorrect because GlideRecord.get() is a server-side method and cannot be used directly in a client script.

34
MCQmedium

A company has a Service Portal that includes a custom widget for submitting hardware requests. The widget has a client controller that calls a server script to create a new record in the 'hardware_request' table. Recently, users have reported that when they click the 'Submit' button, the widget sometimes does not show a success message, and the record is not created. The developer reviews the server script, which uses gs.log to log errors, and sees no errors in the logs. The client controller uses $scope.server.get() to call the server. The widget template uses ng-show='data.success' to display a success message. Based on this scenario, what is the most likely cause of the intermittent issue?

A.The server script fails due to a mandatory field not being provided, but the error is not logged.
B.The server script uses data.success = true; but the client controller does not read it.
C.The widget has a Client Script that conflicts with the server script.
D.The client controller does not handle the asynchronous response properly; the success message depends on the promise resolving before the user might navigate away or click again.
AnswerD

Asynchronous calls require proper handling of promises to update scope.

Why this answer

The client controller uses $scope.server.get() to make an asynchronous call to the server script. If the user clicks 'Submit' and then navigates away or clicks again before the promise resolves, the success message (ng-show='data.success') may never display because the $scope.data object is not updated in time. The server script logs no errors because it executes correctly, but the client-side asynchronous handling fails to capture the response, leading to the intermittent issue.

Exam trap

ServiceNow often tests the misconception that server-side errors are the only cause of missing success messages, but the trap here is that asynchronous client-side handling (promise resolution and digest cycles) can silently fail to update the UI even when the server executes correctly.

How to eliminate wrong answers

Option A is wrong because the server script uses gs.log to log errors, and the developer sees no errors in the logs, indicating that mandatory fields are likely provided and the script executes without failure. Option B is wrong because if the server script sets data.success = true, the client controller would read it via the $scope.server.get() response, which updates $scope.data; the issue is not that the client controller fails to read it, but that the response may not be processed due to asynchronous timing. Option C is wrong because there is no mention of a Client Script in the widget, and a conflicting Client Script would likely produce consistent errors or logs, not intermittent failures with no logged errors.

35
MCQeasy

When configuring a Service Portal page, a developer wants to ensure that a specific widget appears only to users with the 'itil' role. Which approach should be used?

A.Pass a role check from the server script to the client controller via widget options.
B.Write an Access Control Rule (ACL) on the widget's table to restrict access.
C.Set the 'Roles' property on the widget instance within the page designer.
D.Create a UI Policy on the portal table that hides the widget based on user roles.
AnswerC

The Roles property restricts widget visibility to specified roles.

Why this answer

The 'Roles' property on a widget instance within the Service Portal page designer directly controls which roles can view that specific widget. This is the intended declarative approach for role-based visibility at the widget instance level, without requiring custom scripting or ACLs.

Exam trap

The trap here is that candidates often confuse ACLs (which control data access) with widget instance visibility, or incorrectly think UI Policies can be applied to portal widgets, when in fact the 'Roles' property is the dedicated mechanism for this exact use case.

How to eliminate wrong answers

Option A is wrong because passing a role check from server script to client controller via widget options is an unnecessarily complex and non-standard approach; the platform provides the built-in 'Roles' property for this purpose. Option B is wrong because Access Control Rules (ACLs) on the widget's table control CRUD operations on the widget record itself, not the runtime visibility of the widget instance on a portal page. Option D is wrong because UI Policies operate on form fields and records, not on Service Portal widgets; they cannot be applied to portal tables to hide widget instances.

36
MCQhard

A UI Policy with the above condition script never evaluates to true. What is the issue?

A.The condition must be written in AngularJS to work in UI16.
B.The property name is misspelled as 'my.property' but should be 'my_property'.
C.gs.getProperty() is not permitted in UI Policy scripts.
D.The script should not be wrapped in a function; it should directly be the condition expression.
AnswerD

UI Policy condition scripts are evaluated as the script itself, not a function call.

Why this answer

UI Policy condition scripts are evaluated as expressions; they should directly return the condition result without being wrapped in a function. The script must be a single expression that evaluates to true or false. Option A is incorrect because UI16 does not require AngularJS for UI Policy conditions; UI Policy conditions are still evaluated as standard scripts.

Option B is incorrect because there is no evidence of a misspelling, and property names can contain dots. Option C is incorrect because gs.getProperty() is permitted and commonly used in UI Policy scripts.

37
MCQeasy

This client script is attached to the 'category' field on the incident form. When the user changes the category to 'Network', what happens to the short_description field?

A.Nothing happens because newValue equals 'Network' which passes the empty check.
B.The short_description is set to 'Category changed to Network'.
C.An error occurs because setValue cannot be called with a string.
D.The short_description is cleared.
AnswerB

The setValue method updates the field.

Why this answer

The client script checks if the newValue of the 'category' field is not empty and equals 'Network'. When the user changes the category to 'Network', newValue is 'Network', which passes the empty check (newValue !== ''), and then the condition newValue === 'Network' is true. The script then executes g_form.setValue('short_description', 'Category changed to Network'), which sets the short_description field to that string.

Exam trap

The trap here is that candidates may misinterpret the empty check as a guard that prevents any action when newValue is non-empty, but the script only skips if newValue is empty, so when newValue is 'Network', it proceeds to the equality check and executes the setValue call.

How to eliminate wrong answers

Option A is wrong because the empty check (newValue !== '') passes when newValue is 'Network', so the script does not skip execution; it proceeds to the equality check. Option C is wrong because g_form.setValue() can accept a string as the second argument; it sets the field value to that string without error. Option D is wrong because the script explicitly sets the short_description to 'Category changed to Network', not clearing it; clearing would require an empty string or null.

38
MCQeasy

The client script above runs on a text field's onChange event. When the user changes the field, the 'short_description' field is not updated. What is the most likely reason?

A.The script is missing a semicolon after the setValue statement.
B.The 'short_description' field is defined as read-only on the form.
C.g_form is not available in the onChange client script.
D.The script runs before the new value is assigned to the field.
AnswerB

g_form.setValue cannot modify read-only fields.

Why this answer

G_form.setValue() cannot update a read-only field. If 'short_description' is defined as read-only on the form, the script will fail to change its value. Option A is incorrect because a missing semicolon would not prevent the field update; JavaScript allows optional semicolons.

Option C is incorrect because g_form is available in onChange client scripts. Option D is incorrect because the onChange event fires after the new value is assigned to the field, so the script runs with the updated value.

39
MCQmedium

A developer created a custom form section for the 'change_request' table that contains a reference field to 'cmdb_ci'. The section is visible in the form layout for all change request types. However, when the 'type' field is set to 'Emergency', the section should not be visible. The developer added a UI Policy to hide the entire section when type is 'Emergency'. But the section remains visible. After checking, the UI Policy is active and the condition is set correctly. What is the most likely reason the UI Policy is not working, and what is the best fix?

A.The section's 'Visible' checkbox in the form layout must be unchecked and then controlled by the UI Policy
B.UI Policies cannot hide form sections; they only control field-level visibility. The developer should hide each field in the section individually via UI Policy or use a client script to hide the section div
C.The UI Policy must be set to 'Run for all users' and the section must be assigned a 'visible' attribute
D.The UI Policy order is too low; it should be set to a higher priority number
AnswerB

This is the correct analysis and solution.

Why this answer

UI Policies in ServiceNow can only control the visibility of individual fields, not entire form sections. The developer must either hide each field in the section via separate UI Policy conditions or use a client script to hide the section's HTML div element. Option A is incorrect because UI Policies cannot directly target form sections.

Option C is incorrect because there is no 'visible' attribute to assign. Option D is incorrect because the issue is not about order or priority.

40
MCQhard

A large enterprise uses ServiceNow for IT Service Management. They have a custom Service Portal for end-users to submit catalog requests. Recently, mobile users reported that the portal is extremely slow on their devices, while desktop users experience no issues. The portal theme uses many custom CSS animations and high-resolution images. Additionally, the widget client scripts are complex and make multiple GlideAjax calls on page load. The development team wants to optimize mobile performance without redesigning the entire portal. Evaluate the options and select the best course of action.

A.Increase server-side caching for widgets and use a CDN for static assets
B.Consolidate multiple GlideAjax calls into a single server-side script and use mobile-optimized images
C.Remove all custom CSS animations and replace high-res images with scalable vector graphics
D.Implement lazy loading for images and defer all GlideAjax calls until after page load
AnswerB

Reducing the number of server round trips and using lighter images directly improves mobile performance by decreasing network latency and rendering effort.

Why this answer

The best course of action because consolidating multiple GlideAjax calls into a single server-side script reduces the number of network round trips, which is critical for mobile performance where latency and bandwidth are limited. Using mobile-optimized images (smaller dimensions, compressed) directly reduces data transfer and rendering load. Option A (caching and CDN) helps but does not address the initial load issue or the multiple calls.

Option C (removing animations and using SVG) reduces client-side rendering overhead but does not tackle the primary bottleneck of excessive GlideAjax calls. Option D (lazy loading and deferred calls) can improve perceived performance but still initiates the same number of calls eventually, and deferring essential calls may delay functionality.

41
Multi-Selecthard

Which THREE of the following are correct statements about Service Portal client controllers?

Select 3 answers
A.They can use AngularJS services like $http and $timeout.
B.They run on the server and are called via server-side includes.
C.They must define a $scope variable explicitly to bind data to the template.
D.They can call the server using $scope.server.get() or $scope.server.post().
E.They are AngularJS controllers that handle client-side logic.
AnswersA, D, E

AngularJS services are available in client controllers.

Why this answer

Service Portal client controllers are AngularJS controllers that run in the browser. They can use standard AngularJS services such as $http for making AJAX calls to external APIs or the instance, and $timeout for delaying execution, which are both injected as dependencies.

Exam trap

ServiceNow often tests the misconception that client controllers run on the server or require explicit $scope declaration, confusing them with server-side scripts or older AngularJS patterns.

Ready to test yourself?

Try a timed practice session using only User Interface Development questions.