Server Side Scripting Flashcards

1
Q

What are business rules?

A

Server-side logic that executes when database records are queried, updated, inserted, or deleted.

———————————————————————
📁 Server Side Scripting Developer Documentation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

When dealing with business rules, how many “when” options are available?
The when option determines when, relative to database access, business rule logic executes

&

What are those options?

A

4
- before
- after
- async
- display

———————————————————————
📁 Server Side Scripting Developer Documentation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

When will a “before” business rule run?

A

Before business rules execute their logic before a database operation occurs.

———————————————————————
📁 Server Side Scripting Developer Documentation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

When should you use “before” Business Rules?

A

When field values on a record need to be modified before the database access occurs.

———————————————————————
📁 Server Side Scripting Developer Documentation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

When will an “after” business rule run?

A

After business rules execute their logic immediately after a database operation occurs and before the resulting form is rendered for the user.

———————————————————————
📁 Server Side Scripting Developer Documentation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

When should you use an “after” business rule?

A

When no changes are needed to the record being accessed in the database.

———————————————————————
📁 Server Side Scripting Developer Documentation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is an “async” business rule??

A

Like after Business Rules, async Business Rules execute their logic after a database operation occurs.
Unlike after Business Rules, async Business Rules execute asynchronously. Async Business Rules execute on a
different processing thread than before or after Business Rules. They are queued by a scheduler to be run as
soon as possible. This allows the current transaction to complete without waiting for the Business Rules
execution to finish and prevents freezing a user’s screen. Use Async Business Rules when the logic can be
executed in near real-time as opposed to real-time (after Business Rules). For example use async Business
Rules to invoke web services through the REST API. Service level agreement (SLA) calculations are also
typically done as async Business Rules.

———————————————————————
📁 Server Side Scripting Developer Documentation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

When would a “display” business rule run?

A

Display business rules execute their logic when a form loads and a record is loaded from the database.

———————————————————————
📁 Server Side Scripting Developer Documentation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are business rule actions?

A

A configurable way to
- set field values
- add a message to a form
- abort the business rule execution

———————————————————————
📁 Server Side Scripting Developer Documentation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are the three drop down options available when using the “Set Field Values” section of a Business Rule Action?

Examples:
Category _____ Hardware
Requested For _______ Beth Anglin
State ______ closed
Description ________ Short Description

A
  • To (dynamic) : Dynamically determined
  • Same as : The same value as the value of another field
  • To : Hard Coded

———————————————————————
📁 Server Side Scripting Developer Documentation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does the business rule action “Abort Action” do?

A

Stops execution of the business rule and aborts the database operation.

You can use add message in conjunction here to display something if wanted.

———————————————————————
📁 Server Side Scripting Developer Documentation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

When would you want to use the “Abort Action” business rule action?

A

When the script logic determines the database operation should not be performed.

———————————————————————
📁 Server Side Scripting Developer Documentation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What do Business Rule Scripts do?

A

Use the server-side APIs to take different actions.

Some Examples:
- Invoking web services
- Changing field values
- Modifying date formats
- Generating events
- Writing log messages

———————————————————————
📁 Server Side Scripting Developer Documentation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Where can you find the scripting field for Business Rule Scripts?

&

What are the two fields for scripting there?

A

In the advanced tab at the bottom of a business rule (only available if the advanced checkbox is checked).

Condition & Script

———————————————————————
📁 Server Side Scripting Developer Documentation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What does dot-walking, in the context of scripting, provide?

A

Dot-walking allows direct scripting access to fields and field values on related records.

———————————————————————
📁 Server Side Scripting Developer Documentation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the syntax used when dot-walking in scripting?

&

How do you forgo having to manually create this syntax?

A

<object>.<related_object>.<field_name>

Example:
current.u_requested_for.email

&

There is a script tree in ServiceNow that offers syntax creation after clicking on particular fields of interest.

———————————————————————
📁 Server Side Scripting Developer Documentation
</field_name></related_object></object>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What are some examples of things that can be done using the GlideSystem API?

A
  • Find information about the currently logged in user
  • Log Messages (debug, error, warning, info)
  • Add messages to pages
  • Generate Events
  • Execute Scheduled Jobs
    Etc etc

———————————————————————
📁 Server Side Scripting Developer Documentation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Why would you use the GlideRecord class?

A

The GlideRecord class allows the ability to interact with the ServiceNow database from a script.

———————————————————————
📁 Server Side Scripting Developer Documentation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What is the general strategy for GlideRecord interactions?

A
  1. Create a GlideRecord object for the table of interest
  2. Build the query condition(s)
  3. Execute the query
  4. Apply script logic to the records returned in the GlideRecord object

———————————————————————
📁 Server Side Scripting Developer Documentation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Is the GlideRecord API server-side or client-side?

A

It is both.
There is a GlideRecord server-side API
There is also a client-side GlideRecord API for global applications. This client-side API cannot be used in scoped applications.

———————————————————————
📁 Server Side Scripting Developer Documentation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

When using GlideRecord server-side API what method is used to build query conditions?

A

addQuery()

———————————————————————
📁 Server Side Scripting Developer Documentation

22
Q

What are the operators used to handle numbers when using the addQuery method of the GlideRecord class?

A

=
!=
>
>=
<
<=

———————————————————————
📁 Server Side Scripting Developer Documentation

23
Q

What are the operators used to handle strings when using the addQuery method of the GlideRecord class?

A

=
!=
STARTSWITH
ENDSWITH
CONTAINS
DOES NOT CONTAIN
IN
NOT IN
INSTANCEOF

———————————————————————
📁 Server Side Scripting Developer Documentation

24
Q

The addQuery() method is typically passed three arguments, what are they?

&

Sometimes you’ll only see two arguments - which argument is left out and why?

A

Field Name, Operator, and Value.

&

The operator argument does not need to be passed - if it is not passed, then it is assumed to be =

———————————————————————
📁 Server Side Scripting Developer Documentation

25
Q

When you are using GlideRecord and have created multiple queries, how is each additional clause treated?

A

Each is treated as an AND, and adds additional filters as to what information is going to be returned and stored within your particular GlideRecord.

———————————————————————
📁 Server Side Scripting Developer Documentation

26
Q

When using the addQuery() method for GlideRecord, what is returned if no query conditions are included?

A

It would return all records from the table.

———————————————————————
📁 Server Side Scripting Developer Documentation

27
Q

What happens, Out Of Box, if a malformed query executes in runtime?
(addQuery() method with GlideRecord)

&

What property can be enabled to change this functionality? // How is the functionality changed?

A

Out Of Box - All records from the table are returned

&

Property - glide.invalid_query.returns_no_rows
Functionality Change - Returns no records for invalid queries.

———————————————————————
📁 Server Side Scripting Developer Documentation

28
Q

After a GlideRecord has been returned, which method can be used in conjunction with normal JavaScript practices to iterate through all returned records within the GlideRecord object?

A

.next()

———————————————————————
📁 Server Side Scripting Developer Documentation

29
Q

What does the .update() method do within the context of a returned GlideRecord object?

&

What does the .updateMultiple() method do?

A

It will update the database for the specific record iteration pulled from the GlideRecord object.

&

updateMultiple() updates all records in a GlideRecord object

———————————————————————
📁 Server Side Scripting Developer Documentation

30
Q

What method is used in the GlideRecord API to count the number of records returned by a query?

A

.getRowCount()
do NOT use this on a production instance, negative performance impact on database.

———————————————————————
📁 Server Side Scripting Developer Documentation

31
Q

What should be used when trying to determine the number of rows returned by a query on a production instance?
What should not be used?

A

GlideAggregate should be used
.getRowCount() should not be used because of negative performance impact on database

———————————————————————
📁 Server Side Scripting Developer Documentation

32
Q

What can be used if you need an OR condition when building GlideRecord queries?

A

Encoded Queries

———————————————————————
📁 Server Side Scripting Developer Documentation

33
Q

What are Encoded Queries?

A

Encoded queries offer the functionality to create technically complex queries. Syntax for creating Encoded Queries isn’t documented - but there is a functionality within ServiceNow that will write it for you.
You can right click any breadcrumbs on any table after using the filter conditions to build your queries there.

———————————————————————
📁 Server Side Scripting Developer Documentation

34
Q

What method, used in conjunction with ServiceNow created syntax, creates an encoded query?

A

.addEncodedQuery(<ServiceNow>)</ServiceNow>

———————————————————————
📁 Server Side Scripting Developer Documentation

35
Q

What are the properties of the object current?

&

Is there anything important to note about the property values?

A

All the fields for a record and all the GlideRecord methods

&

The property values are the values as they exist in the runtime environment

———————————————————————
📁 Server Side Scripting Developer Documentation

36
Q

What is the syntax for using the current or previous object in a script?

A

<object_name>.<field_property>

———————————————————————
📁 Server Side Scripting Developer Documentation
</field_property></object_name>

37
Q

Do script includes have very many or very little configuration options?

&

Can you explain the reasoning behind this?

A

Script includes have very little configuration options because they are called by other scripts instead of being triggered on their own by events.

———————————————————————
📁 Server Side Scripting Developer Documentation

38
Q

What is the GlideAjax class used by client-scripts for?

A

To send data to and receive data from the ServiceNow server.

———————————————————————
📁 Server Side Scripting Developer Documentation

39
Q

What is the primary difference between different server-side scripts?

A

What triggers the script logic execution

———————————————————————
📁 Server Side Scripting Developer Documentation

40
Q

Provide the following information for the Business Rule server-side script type:

Description:

Often Used To:

Executes On:

A

Description: Execute logic when records are queried, updated, inserted, or deleted.

Often Used To: Validate data or set fields on other records in response to fields on the current record.

Executes On: Database Access

———————————————————————
📁 Server Side Scripting Developer Documentation

41
Q

Provide the following information for the Script Include server-side script type:

Description:

Often Used To:

Executes On:

A

Description: A library of reusable functions

Often Used To: Validate format, retrieve shared records, and work with application properties

Executes On: Must be explicitly called

———————————————————————
📁 Server Side Scripting Developer Documentation

42
Q

Provide the following information for the Script Action server-side script type:

Description:

Often Used To:

Executes On:

A

Description: Respond to an event

Often Used To: Send email notifications or write logging information

Executes On: Events

———————————————————————
📁 Server Side Scripting Developer Documentation

43
Q

Provide the following information for the Scheduled Script Execution server-side script type:

Description:

Often Used To:

Executes On:

(This is also known as a Scheduled Job)

A

Description: Script logic executed on a time-based schedule

Often Used To: Create reports: send daily, weekly, monthly, quarterly, and annual information. Execute script logic only on weekdays or weekends. Can also run on demand so sometimes used for testing.

Executes On: Time

———————————————————————
📁 Server Side Scripting Developer Documentation

44
Q

Provide the following information for the UI Action server-side script type:

Description:

Often Used To:

Executes On:

A

Description: Add buttons, links, and context menu items to forms and lists to allow users to perform application-specific operations.

Often Used To: Enable users to perform actions such as navigating to another page, modifying records, or allowing operations such as saving.

Executes On: Users

———————————————————————
📁 Server Side Scripting Developer Documentation

45
Q

Provide the following information for the Scripts - Background server-side script type:

Description:

Often Used To:

Executes On:

A

Description: Execute server-side code on demand from a selectable scope. Scripts - Background should be used with caution because badly written scripts can damage the database

Often Used To: Test scripts.

Executes On: admin users only (some instances require the security_admin role)

———————————————————————
📁 Server Side Scripting Developer Documentation

46
Q

Provide the following information for the Fix Scripts server-side script type:

Description:

Often Used To:

Executes On:

A

Description: Make changes that are necessary for the data integrity or product stability

Often Used To: Create or modify groups or user authorizations

Executes On: Application installation or upgrade

———————————————————————
📁 Server Side Scripting Developer Documentation

47
Q

Provide the following information for the Notification Email Script server-side script type:

Description:

Often Used To:

Executes On:

A

Description: Execute when emails are generated to add content to the email content or configuration

Often Used To: Add a CC or BCC email address, or query the database and write information to the message body.

Executes On: Notification

———————————————————————
📁 Server Side Scripting Developer Documentation

48
Q

Provide the following information for the Scripted REST APIs server-side script type:

Description:

Often Used To:

Executes On:

A

Description: Defines a web service endpoint

Often Used To: Return value(s) or a JSON object based on a calculation or database lookup(s)

Executes On: Request sent or received through web services

———————————————————————
📁 Server Side Scripting Developer Documentation

49
Q

Provide the following information for the UI Page Processing Script server-side script type:

Description:

Often Used To:

Executes On:

A

Description: Executes when a UI Page is submitted

Often Used To: Validate data, set values, etc

Executes On: Users

———————————————————————
📁 Server Side Scripting Developer Documentation

50
Q

Provide the following information for the Transform Map Script server-side script type:

Description:

Often Used To:

Executes On:

A

Description: Modifies or copies data or data format when records are imported

Often Used To: Standardize date formats, fill in missing data, standardize values, map incoming values to database values for choice lists, set default values.

Executes On: Data Import

———————————————————————
📁 Server Side Scripting Developer Documentation

51
Q

Which of the following are classes in the ServiceNow server-side API?
(More than one response may be correct)

1 - GlideSystem (gs)
2 - GlideUser (g_user)
3 - GlideDateTime
4 - GlideDate
5 - GlideForm (g_form)

A

1, 3, and 4 are correct.

The server-side API also has a GlideUser class but the server-side GlideUser class does not use the g_user object.

———————————————————————
📁 Server Side Scripting Developer Documentation

52
Q

What is something important to remember within the context of a “display” business rule’s completion?

A

Execution must be completed before
control of the form can be given over to a user.

———————————————————————
📁 Server Side Scripting Developer Documentation