Server Side Scripting Flashcards
What are business rules?
Server-side logic that executes when database records are queried, updated, inserted, or deleted.
———————————————————————
📁 Server Side Scripting Developer Documentation
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?
4
- before
- after
- async
- display
———————————————————————
📁 Server Side Scripting Developer Documentation
When will a “before” business rule run?
Before business rules execute their logic before a database operation occurs.
———————————————————————
📁 Server Side Scripting Developer Documentation
When should you use “before” Business Rules?
When field values on a record need to be modified before the database access occurs.
———————————————————————
📁 Server Side Scripting Developer Documentation
When will an “after” business rule run?
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
When should you use an “after” business rule?
When no changes are needed to the record being accessed in the database.
———————————————————————
📁 Server Side Scripting Developer Documentation
What is an “async” business rule??
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
When would a “display” business rule run?
Display business rules execute their logic when a form loads and a record is loaded from the database.
———————————————————————
📁 Server Side Scripting Developer Documentation
What are business rule actions?
A configurable way to
- set field values
- add a message to a form
- abort the business rule execution
———————————————————————
📁 Server Side Scripting Developer Documentation
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
- To (dynamic) : Dynamically determined
- Same as : The same value as the value of another field
- To : Hard Coded
———————————————————————
📁 Server Side Scripting Developer Documentation
What does the business rule action “Abort Action” do?
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
When would you want to use the “Abort Action” business rule action?
When the script logic determines the database operation should not be performed.
———————————————————————
📁 Server Side Scripting Developer Documentation
What do Business Rule Scripts do?
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
Where can you find the scripting field for Business Rule Scripts?
&
What are the two fields for scripting there?
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
What does dot-walking, in the context of scripting, provide?
Dot-walking allows direct scripting access to fields and field values on related records.
———————————————————————
📁 Server Side Scripting Developer Documentation
What is the syntax used when dot-walking in scripting?
&
How do you forgo having to manually create this syntax?
<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>
What are some examples of things that can be done using the GlideSystem API?
- 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
Why would you use the GlideRecord class?
The GlideRecord class allows the ability to interact with the ServiceNow database from a script.
———————————————————————
📁 Server Side Scripting Developer Documentation
What is the general strategy for GlideRecord interactions?
- Create a GlideRecord object for the table of interest
- Build the query condition(s)
- Execute the query
- Apply script logic to the records returned in the GlideRecord object
———————————————————————
📁 Server Side Scripting Developer Documentation
Is the GlideRecord API server-side or client-side?
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