96 questions from the Application Automation domain of the ServiceNow Certified Application Developer (CAD) exam, each with its answer and an explanation. Read them through as revision, then sit the full practice exam to test yourself on them under multiple-choice conditions.
Answer
A scheduled job runs on the server on a schedule, not against a particular record, so there is no current object. Server-side APIs such as GlideSystem (gs) and GlideRecord are available, while GlideUser (g_user) is a client-side object.
Answer
gs.log() is not available in scoped applications. Scoped server-side scripts log messages with gs.info(), gs.warn(), gs.error() and gs.debug().
Answer
When a notification is fired by an event, its email scripts receive an event object, and the event's parameters are read as event.parm1 and event.parm2. The ${...} syntax inserts field values into the notification's message text; it isn't used inside an email script.
Answer
A utils script include is a class of reusable functions, so you create the class, create its prototype object and script the functions. It isn't tied to a table, so identifying one is not part of the process.
Answer
Wrapping a function in parentheses and calling it straight away, as the business rule template does, makes it a self-invoking function (an immediately invoked function expression). It runs once, and its variables stay inside the function instead of leaking into the global scope.
Answer
Flows can call subflows, can be built by delegated developers and can be started by a MetricBase trigger. Testing a flow runs it on the instance, and there is no option to roll back the records it changed.
Answer
Weight defaults to zero, and a notification with a weight of zero is always sent when its When to send criteria are met. When several weighted notifications fire for the same record and recipients, only the one with the highest weight is sent.
Answer
A display business rule runs when a record is read from the database, before the form is shown, so nothing has changed and there is no previous object. It can use current, GlideSystem and g_scratchpad, which passes values to client scripts.
Answer
A spoke is a scoped application that packages Flow Designer actions and subflows for one application or service, such as the Jira or Slack spokes. Actions and flows are the content a spoke provides or uses.
Answer
Client-side and server-side scripts, such as client scripts, business rules and script includes, are written in JavaScript to extend the platform and add functionality. Logos, banner text and email display names are set through configuration, not scripts.
Answer
The Field Watcher follows one field on a form and traces how scripted logic, such as business rules, client scripts and the script includes they call, changes its value. It doesn't debug how access controls are evaluated; security rules are debugged separately.
Answer
An inbound email action script works with current, the record being created or updated, and email, which holds the incoming message's sender, subject and body. previous, event and producer belong to business rules, notifications and record producers.
Answer
A notification is set up in three sections: When to send, Who will receive and What it will contain. There is no separate How to send section.
Answer
The Script Tracer records the server-side scripts that run during a transaction and lets you filter them, for example by table or script type, so you can find the script causing a problem and open it in the Script Debugger. The other options are not Script Debugger features.
Answer
ScopedSessionDomain gives scoped scripts information about the session's domain in a domain-separated instance, and getCurrentDomainID() returns the sys_id of the domain the user is currently in. GlideSession, GlideRecord and ScopedDCManager don't provide this method.
Answer
Debug Business Rule shows which business rules ran or were skipped. Debug Business Rule (Details) also shows the old and new value of each field a business rule changed, so you can see what a rule actually did to the record.
Answer
Script actions are reusable server-side scripts. They respond to events, and they can also be triggered through business rules when a record meets certain conditions, so the same logic can be run from either.
Answer
The Script Debugger steps through server-side scripts, such as business rules and script includes. Client-side scripts run in the browser, so they are debugged with the browser's developer tools, jslog() or messages on the form.
Answer
gs.nowDateTime() is not available in scoped applications. A new GlideDateTime object holds the current date and time, and getDisplayValue() returns it in the user's format and time zone.
Answer
An event has to be in the Event Registry before notifications and script actions can be set up to respond to it. Registering it also documents what fires the event and on which table.
Answer
Workflows automate processes on the server, such as approvals, tasks and notifications. UI actions are buttons, links and menu items that users click, so they are not something a workflow runs.
Answer
A before business rule receives current, holding the values being saved, and previous, holding the values in the database. Its script can also create GlideRecord objects to query other tables.
Answer
A notification can be sent when a record is inserted or updated and meets its conditions, when a specific event is fired, or when it is triggered directly, for example from a flow or a script.
Answer
gs.getProperty() returns the value of a system property on the server and can take a default value to use if the property doesn't exist. g_form has no property methods, and gs.getAppProperty() does not exist.
Answer
A workflow automates a process as a sequence of activities, such as approvals, tasks, notifications and timers. A business rule runs logic when a record changes, and a UI action adds a button or link for users.
Answer
While a workflow is checked out, the changes are used only by the user who checked it out, so they can test them. Everyone else keeps running the published version until the workflow is published.
Answer
An event record is added to the event queue [sysevent] when something notable happens, for example when a business rule calls gs.eventQueue(), and notifications and script actions respond to it. Script actions and UI actions are logic, and the ECC Queue holds MID Server communication.
Answer
A scheduled job runs a script on the server at set times, with no browser or form involved. Client-side scripts only run in a user's browser, on a form or list the user has open.
Answer
gs.isInteractive() returns true when the current session belongs to a user working in the browser, and false for non-interactive sessions such as scheduled jobs, imports and web service requests. Business rules use it to run logic only for interactive users, or only for non-interactive ones.
Answer
gs.getUserID() returns the sys_id of the logged-in user on the server. g_form only exists in the browser, and getUserSysID() is not a GlideSystem method.
Answer
The GlideRecord method that checks whether a record hasn't been saved yet is isNewRecord(), so business rules and access control scripts use current.isNewRecord().
Answer
The Field Watcher watches one field at a time. To debug another field, you stop watching the current one and start watching the next.
Answer
Approvals, notifications and tasks are the basic building blocks of most workflows: getting authorization, keeping people informed and assigning work. Timers and scripts are also available as supporting activities.
Answer
The Flow Designer help panel shows information about the flow and the actions added to it, such as what each action does. The other options are not Flow Designer features.
Answer
Setting glide.debug.log_point to true enables logpoints, so messages can be logged at chosen lines of a script without changing the script. The other properties control different features.
Answer
Flow variables appear in the data panel as data pills, which you drag into action inputs and conditions. Scratchpad variables belong to workflows and client scripts, not Flow Designer.
Answer
Incident auto-resolution works with Virtual Agent to reach the user after they submit an incident and offer answers, such as knowledge articles, so they can resolve it themselves. The other options are not ServiceNow capabilities.
Answer
Common notification content is written once and reused across notification channels, so the message stays consistent and only needs to be maintained in one place. The other options are not the feature for sharing content between channels.
Answer
A script include is found by its name, so the class it defines must have the same name, for example var MyUtils = Class.create(); in a script include called MyUtils. Otherwise other scripts can't create the class with new MyUtils().
Answer
Virtual Agent is a chatbot that holds conversations with users to answer questions and complete tasks, such as checking a request or resetting a password. It is separate from assignment features and from Flow Designer, although its conversations can run flows.
Answer
Agent Intelligence, now called Predictive Intelligence, uses machine learning trained on historical records to predict and set field values, such as the category or assignment group of a new incident. Assignment rules and integrations are separate features.
Answers
A flow is built from a trigger and actions, the data panel shows the data pills they can use, and executions show the details of each time the flow ran. The script debugger and developer tools are not part of Flow Designer.
Answer
Scheduled jobs move through states such as Ready, Queued, Running and Error as the scheduler processes them. Waiting for approval is an approval state, not a scheduled job state.
Answer
gs is the server-side GlideSystem object, so gs.getProperty() works only in server scripts. A client script that needs a property value gets it from the server, for example through g_scratchpad or GlideAjax.
Answer
The method is gs.minutesAgo(), with a capital A, and it takes the number of minutes, so gs.minutesAgo(30) returns the date and time 30 minutes ago for use in a query. gs.minute() is not a GlideSystem method.
Answer
GlideRecord normally saves an update only when a field value has changed. Calling setForceUpdate(true) before update() makes the update run anyway, for example to trigger business rules on the record without changing its data. It applies to that record, not to every record in the table.
Answer
The script formats today's date as MM-dd-yyyy with getFormat(), converts the result to a string, removes the dashes with replace() and prints it with gs.print().
Answer
gs.nil() returns true when a value is null, undefined or an empty string, so it is the standard check for an empty value in server scripts. gs.is_nil() is not a GlideSystem method.
Answer
setWorkflow(false) stops the update from running business rules, so calling it before current.update() prevents the rule from triggering itself again. setWorkflow(true) is the default and leaves them running.
Answer
gs.print() writes only to the text log file on the server. gs.info() and gs.log() also create records in the System Log table.
Answer
sys_mod_count counts how many times a record has been updated. Adding MIN, MAX and AVG aggregates on it, grouped by category, returns the lowest, highest and average number of modifications for each category.
Answer
In a before business rule, current.setAbortAction(true) cancels the insert, update or delete that triggered the rule, so the record isn't saved. AbortAction() is not a GlideRecord method.
Answer
The script loops through the sc_task records and, for each one, queries the Task table for the record with the same sys_id, which is the same record seen through its parent table, and prints its work notes.
Answer
gs.getUser() returns a user object for the logged-in user, with methods such as getFullName() and hasRole(). gs.User() is not a GlideSystem method.
Answer
Workflows are identified by sys_id rather than by name, so two workflows can have the same name, for example in different domains. Unique names are still a good idea to avoid confusion.
Answer
The watermark lets the instance match a reply email to the record the notification was about, so inbound email actions update the right record. Its random string makes each watermark unique.
Answer
In a notification, ${URI_REF} inserts a link to the record whose text is the record's display value, such as its number. ${URI} inserts a link whose text is the word LINK.
Answer
A business rule that calls a script include while a form is submitted runs inside that interactive transaction, so the user's request waits until the script finishes. A Script Debugger transaction doesn't outlive the session: when the user logs out or the session times out, it ends.
Answer
Notifications are sent when a record meets their conditions or when an event is fired. MID Servers carry communication with systems on other networks and don't trigger notifications.
Answer
gr.autoSysFields(false) turns off the automatic update of system fields such as Updated and Updated by, and it must be called before gr.update() to affect that update. Passing true or a string, or calling it after the update, doesn't do this.
Answer
Flows can be started by a record trigger when a record is created or updated, by a date trigger that runs at a set time or on a schedule, or by an application trigger, such as a service catalog request or an inbound email.
Answer
current.setAbortAction(true) cancels the database action and stops the system from running the remaining, higher-order business rules for that operation. return false only ends the current script, so it isn't how a business rule cancels an action.
Answer
In workflow activity scripts on a requested item, current.variable_pool gives access to the item's catalog variables. Client scripts read variables with g_form instead.
Answer
setWorkflow(false) stops business rules and other engines from running for that database operation. Whether changes are audited is controlled separately by the table's audit settings.
Answer
A before insert business rule runs before the record is saved, so when it finds the short description is test it can abort the insert. No incident is created, and the user sees an invalid insert error.
Answer
An async business rule runs in the background after the record has been saved, so it can be set to run on insert, update or delete. Query isn't available, because a query business rule has to run before the data is returned to the user.
Answer
gs.getSession() is valid and returns a GlideSession object, and getClientData() reads a value stored in the session. The method that stores the value is putClientData(), so the call to setClientData() is the problem.
Answer
A client script can't call a script include directly. The script include has to extend AbstractAjaxProcessor so it can be called from the client, and the client script then calls it with GlideAjax.
Answer
Business rules run on the server, where GlideRecord and GlideSystem are available. GlideForm (g_form) and GlideUser (g_user) are client-side objects, so business rules can't use them.
Answer
A notification's When to send section sets when it is sent, Who will receive includes options such as excluding delegates and sending to the event creator, and What it will contain sets the content.
Answer
GlideRecord's addJoinQuery() adds a condition that returns records from the main table only when related records exist in a second table, so a single query uses both tables. JoinQuery() is not a GlideRecord method.
Answer
addQuery() returns a query condition, and calling addOrCondition() on it adds an OR, so the query returns incidents whose category is server or desktop. addQuery() doesn't combine two values when they are passed this way.
Answer
deleteMultiple() deletes every record that matches the GlideRecord's current query, together with their attachments, while deleteRecord() deletes the single record the GlideRecord is on.
Answer
Flows can start from record, schedule and application triggers. Sending an email is an action a flow performs, not something that starts one.
Answer
In a notification's message, ${event.<property>} inserts a value from the event that fired it, such as ${event.parm1}. ${current.<field>} inserts values from the record instead.
Answer
Setting the glide.email.watermark.visible property to false hides the watermark in all outgoing emails. glide.email.watermark.is_visible is not a property.
Answer
By default, a query condition with an invalid field name is ignored, so the query can return far more records than intended. Enabling the glide.invalid_query.returns_no_rows property makes such queries return no rows instead.
Answer
Setting glide.pop3readerjob.create_caller to true makes the instance create a user record when an email arrives from an address that doesn't belong to an existing user, so the email can be processed with that user as the caller.
Answer
The Insert, Update, Delete and Query check boxes decide which database operations trigger a business rule, and When only sets its timing. With none of them selected, nothing triggers the rule, so it never runs even though it is active.
Answer
A subflow has no trigger of its own; it runs only when a flow, another subflow or a script calls it. That makes it the right choice for a reusable sequence of steps shared by several flows.
Answers
A flow triggered when an incident task is created can set Assigned to without scripting, and a before insert business rule can set it in script before the record is saved. Data policies and UI policies control whether fields are mandatory, read-only or visible; they don't set values when records are created.
Answer
gs.debug() writes debug-level messages from scoped server-side scripts, which appear in the log when debugging is enabled for the application. gs.log() isn't available in scoped applications, gs.addInfoMessage() shows a message to the user, and gs.info() logs informational messages rather than debug output.
Answer
In a notification's message, ${current.<field>} inserts the value of a field from the record the notification is about, so ${current.short_description} adds the record's short description.
Answer
Unmatched emails aren't moved to a junk folder. If the sender matches a user, that user is impersonated while the inbound actions run, and scripts can use methods such as gs.getUserName(). If there is no match and automatic user creation is disabled, the Guest user is used instead.
Answers
An application can respond to an event with email notifications and script actions set up for that event, and with scheduled jobs. UI policies only change how fields behave on a form, so they don't respond to events.
Answer
In Flow Designer, a flow is a trigger followed by a sequence of actions, such as creating records, asking for approval or sending notifications, that automate a process. It is built visually rather than as a script, and activities are the building blocks of legacy workflows.
Answers
Working with events means adding the event to the Event Registry, generating it, for example with gs.eventQueue(), and responding to it with a notification or script action. A scheduled script execution or business rule may be where the event is generated, but they aren't steps of the process itself.
Answers
Flows are built from core actions such as Ask for Approval and Send Notification, flow logic such as conditions and timed waits, and subflows that package reusable steps. Service Catalog is a trigger that starts a flow, not an action or flow logic.
Answers
current and GlideSystem are available in every business rule. previous has no earlier values to hold in some business rules, such as those that run on insert, and g_scratchpad is only used in display business rules to pass data to the client.
Answer
Server-side scripts, such as business rules, script includes and scheduled jobs, run on the server and work with the database and back-end logic. Forms and fields are handled by client-side scripts, and user access by roles and access controls.
Answer
A script action runs when its event is processed and receives event, with the event's parameters, and current, the record the event was fired for, and it can create GlideRecord objects. There is no previous object, because the script action isn't running as part of a record update.
Answer
On its Actions tab, a business rule can set field values and show a message to the user without a script. Querying the database, writing to the system log and generating events all need a script.
Answers
In Virtual Agent scripts, vaSystem holds system information about the conversation, including the user, and vaInputs holds the values collected during the conversation, which can include the user. There is no vaUser object, and vaVars holds the topic's own script variables.
Answers
A topic can be tried out with the Preview button, which is available both on the topic list and on the topic record and opens a test conversation. There are no Run Active Topics or Preview Active Topics buttons.
Answer
Glide Virtual Agent is the core plugin for Virtual Agent, and activating it also activates the related Virtual Agent plugins. The designer and web client are parts of Virtual Agent rather than the plugin that turns it on.
Answer
Virtual Agent matches what a user types against each topic's keywords to decide which topic to start. Tags organize topics, the description is informational, and conditions decide whether a topic is available to a user.