CCNA User Interface Development Questions

42 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

Option C is correct because 'sp' is the Service Portal client-side API which must be injected via dependency. Option A is incorrect because angular is not needed for sp. Option B is incorrect because widget order on the page does not affect individual widget dependencies.

Option D is incorrect because the server script runs first; the error is client-side.

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, E. B: Excessive client scripts slow down form loading. C: Large number of catalog items in a variable set.

E: Unoptimized GlideRecord queries on server scripts in UI Macros. A: Using CSS variables improves performance. D: UI Policies with simple conditions are efficient.

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

Option C is correct because UI Policies execute on the server when the form is loaded, but client-side mandatory validation requires the UI Policy to set the mandatory attribute on the client copy. If the policy is set to run only on the server, the client does not enforce it. Option A is wrong because client scripts can set mandatory but are not the standard way.

Option B is wrong because ACLs control access, not mandatory. Option D is wrong because the form load order is usually correct.

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

Option D is correct because Jelly UI elements must be directly inside a <g:ui_element> or <g:ui_section>; nesting <g:ui_element> inside another <g:ui_element> is invalid and causes the inner element to be ignored. Option A is incorrect because the 'mandatory' attribute is on 'short_description', not on 'cmdb_ci'. Option B is incorrect because there is no such namespace issue.

Option C is incorrect because the Jelly syntax is correct for other fields.

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

Option C is correct because `$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
MCQeasy

A developer needs to add a custom button to the incident form that executes a script when clicked. Which mechanism should be used?

A.Write a client script that adds a button dynamically.
B.Modify the form layout to include a button widget.
C.Create a UI Action.
D.Configure a UI Policy.
AnswerC

UI Actions are the standard way to add buttons with server-side actions.

Why this answer

Option A is correct because UI Actions define custom buttons that appear on forms and run server-side scripts. Option B is wrong because UI Policies control field behavior, not buttons. Option C is wrong because client scripts run on events but do not create buttons.

Option D is wrong because form layout arranges fields, not buttons.

8
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.

9
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

Option A is correct because `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.

10
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.
AnswerA

UI Policy can conditionally display UI elements and run client scripts.

Why this answer

Option A is correct because UI Policies in Service Portal allow you to define client-side conditions and scripts that can dynamically show or hide UI elements like buttons. By creating a UI Policy on the incident table with a client script, you can conditionally display a custom button that triggers a confirmation dialog before form submission, leveraging the client-side execution context without server round-trips.

Exam trap

The trap here is that candidates often confuse UI Policies with UI Actions, thinking UI Actions are the only way to add buttons, but UI Policies are specifically designed for conditional client-side UI behavior, including showing buttons and triggering client scripts, which matches the requirement for a confirmation dialog before submission.

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.

11
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

Correct options A and B. A: onChange fires when a field value changes. B: onSubmit fires when the form is submitted.

C: onLoad is actually a separate type but the name 'onLoad' is correct; the option says 'onLoad' which is valid but we have to choose two. Actually careful: options are A: onChange, B: onSubmit, C: onLoad, D: onDelete, E: onUpdate. The valid types are onChange, onSubmit, onLoad, and onCellEdit.

So A and B are valid; C is also valid but we need exactly two correct. The stem says 'Which TWO' but if three are valid, we need to ensure only two are listed as correct. In this case, we'll make A and B correct, and C incorrect (maybe 'onLoad' is not a type? Actually it is.

But we can say 'onLoad' is not a value for the 'Type' field? Wait, client script types: onChange, onSubmit, onLoad, onCellEdit. So onLoad is valid. To make only two correct, we can change the options: e.g., A: onChange (correct), B: onSubmit (correct), C: onLoad (incorrect?) No, onLoad is correct.

Let's adjust: replace option C with something else like 'onClick' which is not a standard type. So we'll set: A: onChange (correct), B: onSubmit (correct), C: onClick (incorrect), D: onDelete (incorrect), E: onUpdate (incorrect). That works.

12
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

Option D is correct because a polling interval with a reasonable delay (e.g., 30 seconds) balances freshness and server load. Option A is incorrect because using 'spNavigation' to reload the entire page causes a full page reload, which is inefficient. Option B is incorrect because WebSocket-like channels are not native to Service Portal and require custom setup; plus, real-time is not needed.

Option C is incorrect because calling the GlideAjax each time the user interacts with the widget misses updates when the user is not interacting.

13
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

Option B is correct because if no records satisfy the condition (active=true but all are inactive), the list will be empty. Option A is wrong because the field is not read-only if the user can click it. Option C is wrong because ACLs are unrelated to reference qualifier results.

Option D is wrong because a dictionary override is not needed for a standard reference field.

14
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

Option A is correct because the GlideRecord API is not available on the client side; using it directly in a client script causes this error. Option B is wrong because server-side scripts can use GlideRecord without error. Option C is wrong because GlideRecord is not deprecated.

Option D is wrong because the error is clearly in a client script.

15
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

Option D is correct because 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.

16
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

Option C is correct because 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.

17
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

Option B is correct because in ServiceNow portal widgets, the server-side data is passed via the 'c' object, and client scripts can modify 'c.data' which is accessible in the HTML template. Option A is wrong because using $scope directly is not recommended in portal widgets; 'c' is the scoped context. Option C is wrong because $rootScope is global and should be avoided.

Option D is wrong because factories are for reusable services, not for widget-specific data binding.

18
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

Option B is correct because 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.

19
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

Option A is correct because the server script in the widget is responsible for querying data; if it has an error, no data is returned. Option B is wrong because ACL issues would typically cause an error message or empty result but less common than script errors. Option C is wrong because client script errors would affect interactivity, not initial loading.

Option D is wrong because the portal page configuration is usually fine if the widget renders.

20
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

Option A is correct because CSS variables allow centralized theme management. Option B is incorrect because inline styles are not maintainable. Option C is incorrect because overriding the theme record directly may be lost on upgrade.

Option D is incorrect because LESS variables in widgets are scoped and less reusable across the portal.

21
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

Option B is correct because a blank UI page without console errors often indicates that the page lacks the required processing directive or that the HTML content is missing due to an ACL restriction. Since there are no errors, the page is being reached, but the content is suppressed. Option A is incorrect because the processing type does not cause a blank page.

Option C is incorrect because if the page was not published, it would typically show an authorization error. Option D is incorrect because a missing client script would not cause the entire page to be blank.

22
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

Option C is correct because form sections are the standard way to group fields on a form. Option A is incorrect because UI Policies do not create sections. Option B is incorrect because UI Pages are not for form layout.

Option D is incorrect because catalog client scripts are for service catalog forms, not standard forms.

23
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.

24
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

Options A and C are correct. In a widget, 'c.data' is the primary data binding mechanism, and 'g_form.setValue()' can be used if a form is present (e.g., in a widget that includes a form). Option B is wrong because $scope is AngularJS but not the recommended pattern.

Option D is wrong because g_list is for list forms, not standard forms. Option E is wrong because spUtil does not have a setValue method.

25
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

Correct options A and B. A: UI Pages are created via the 'UI Page' module. B: Service Portal widgets also render UI but are separate.

C: UI Macros are reusable components, not pages. D: Form sections are layout elements on existing forms. E: Client scripts are code snippets, not pages.

26
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

Option B is correct because combining queries into a single GlideAggregate reduces database calls. Option A is incorrect because caching may help only if queries are repeated. Option C is incorrect because using client-side GlideAjax moves load to client but does not reduce server processing.

Option D is incorrect because asynchronous loading does not reduce total server work.

27
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

Option B is correct because 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.

28
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

Option B is correct because a client script that runs on load can overwrite the value set by the business rule. Option A is wrong because asynchronous business rules still run in the same transaction and the value would be saved. Option C is wrong because UI Policies control visibility, not values.

Option D is wrong because the form reloads after submission, so it should reflect the updated value.

29
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

Option B is correct because the most common issue is a syntax error in the macro definition that prevents rendering. Option A is wrong because checking the HTML source is possible but not the first step. Option C is wrong because UI Scripts are separate from macros.

Option D is wrong because scope issues are less likely than syntax errors.

30
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

Option A is correct because UI16 themes are managed through the 'sys_ui_theme' table. Option B is wrong because UI Scripts are for JavaScript functions, not themes. Option C is wrong because branding records are for logos and colors but not full themes.

Option D is wrong because portal themes are for Service Portal, not UI16.

31
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

Option B is correct because checking the UI Policy conditions and order is the logical first step. Option A is incorrect because the field must already exist. Option C is incorrect because UI Policies do not use script includes.

Option D is incorrect because ACLs do not affect mandatory behavior.

32
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 D are correct. UI Actions can be created directly via the UI Actions module (sys_ui_action) or by duplicating an existing one. Option B is wrong because Form Design is for layout, not UI Actions.

Option C is wrong because Script Includes are separate server-side scripts. Option E is wrong because Business Rules are a different record type.

33
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

Option B is correct because UI Policies are designed to control field visibility, read-only, and mandatory states on forms based on conditions. Option A is wrong because the form layout only defines the initial arrangement but does not dynamically hide fields. Option C is wrong because client scripts can set values but are not ideal for visibility control; UI Policy is declarative and more efficient.

Option D is wrong because a catalog client script could be used but is less standard than UI Policy for visibility.

34
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

Option D is correct because g_form is the standard client-side API for form manipulation. Option A is incorrect because GlideRecord is server-side only. Option B is incorrect because g_l is for GlideAjax.

Option C is incorrect because g_form.getValue() requires the field name as a string, not the element ID.

35
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.

36
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

Option C is correct because 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.

37
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

Option B is correct because UI Policy condition scripts should not be wrapped in a function; the entire script is the condition expression. The code should directly return the property comparison, not define a function. Option A is wrong because gs.getProperty is allowed in UI Policy conditions (server-side).

Option C is wrong because there is no evidence of a misspelling. Option D is wrong because UI Policies are not related to AngularJS.

38
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

Option B is correct because 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.

39
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

Option C is correct because if the target field ('short_description') is set to read-only, g_form.setValue() will not change its value. Option A is wrong because semicolons are optional in JavaScript and missing one would not cause this specific issue. Option B is wrong because g_form is available in client scripts.

Option D is wrong because the onChange event fires after the new value is set.

40
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

Option C is correct because UI Policies can only control individual field visibility, not entire form sections. The best fix is to hide all fields in the section, or use a client script to hide the section via CSS. Option A is incorrect because UI Policies cannot directly target form sections.

Option B is incorrect because there is no default order issue; UI Policies work on fields. Option D is incorrect because the section has no 'visible' attribute.

41
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

Option D is correct because reducing unnecessary client-side processing and network calls directly addresses mobile performance bottlenecks. Option A is incorrect because lazy loading helps initial load but does not reduce total number of calls; it may still be heavy. Option B is incorrect because caching only helps repeated visits, not the first load.

Option C is incorrect because disabling animations reduces rendering, but the main issue is likely the GlideAjax calls and assets; option D combines reducing server calls and optimizing assets.

42
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

Option A is correct because 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.