Vancouver - Scheduled Script Executions and Events COPY Flashcards

1
Q

DEVELOPER TIP: Although not the primary use case, ___ ___ ___ are useful for testing server-side script logic because they can be configured to execute on demand.

A

DEVELOPER TIP: Although not the primary use case, Scheduled Script Executions are useful for testing server-side script logic because they can be configured to execute on demand.

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

DEVELOPER TIP: To run a Scheduled Script Execution on the last day of the month, configure a monthly Scheduled Script Execution set to run on day __. The Scheduled Script Execution will run on the last day of the month, even for months with fewer than __ days.

A

DEVELOPER TIP: To run a Scheduled Script Execution on the last day of the month, configure a monthly Scheduled Script Execution set to run on day 31. The Scheduled Script Execution will run on the last day of the month, even for months with fewer than 31 days.

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

Scheduled Script Executions are not associated with ___ and have no access to the ___ or ___ objects used by many other server-side script types.

A

Scheduled Script Executions are not associated with records and have no access to the previous or current objects used by many other server-side script types.

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

Scheduled Script Executions have two scripting fields:

___
___

A

Scheduled Script Executions have two scripting fields:

Condition
Run this script

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

The Condition script shown tests what? The script returns true only for ___.

A

If today is a weekday or weekend. Weekdays

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

The server-side script logic in the Run this script field executes when the Scheduled Job is triggered and the Condition script returns true.

The script shown queries the database for?

A

The server-side script logic in the Run this script field executes when the Scheduled Job is triggered and the Condition script returns true.

The script shown queries the database for Occasion records that match today’s month and day and logs the record numbers in the Application Log (System Logs > System Log > Application Logs).

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

Variables declared in the Condition script are known to the ___ ___ ___ field if permitted by the rules of JavaScript scope.

A

Variables declared in the Condition script are known to the Run this script field if permitted by the rules of JavaScript scope.

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

NOTE: If the Scheduled Script Execution includes a Condition script, the Condition script must set the answer variable to true for the Run this script field’s script to execute, even when using the ___ ___ button to test the Scheduled Script Execution.

A

NOTE: If the Scheduled Script Execution includes a Condition script, the Condition script must set the answer variable to true for the Run this script field’s script to execute, even when using the Execute Now button to test the Scheduled Script Execution.

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

Where would I find the outputs of the following line in a scheduled script that was executed:

gs.info(‘This is the text’);

A

System Logs > System Log > Application Logs

I’m not sure that this is true if the application isn’t scoped (this was done in the needit application via studio)

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

What is the following solution doing:

var rightNow = new GlideDateTime();

var dueSoon = new GlideRecord(‘x_58872_needit_needit_task’);
dueSoon.addQuery(‘due_date’,’>=’,rightNow);
dueSoon.addQuery(‘due_date’,’<’,gs.hoursAgo(-24));
dueSoon.addQuery(‘state’,’!=’,3);

dueSoon.query();

A

This code gets NeedIt records that are due in the next 24 hours that are not already in a state of complete.

This solution uses the GlideSystem hoursAgo() method. When passed a positive number, the method looks into the past. When passed a negative number, the method looks into the future. It may seem counterintuitive for a negative number to reference the future. The method is hoursAgo(), which is why positive numbers are in the past. Two hours ago is a positive number.

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

Events are an indication in ServiceNow that something notable has occurred. Events can be generated by server-side scripts, workflows, ServiceNow processes, or by user actions such as:

____
____
____
____

A

Events are an indication in ServiceNow that something notable has occurred. Events can be generated by server-side scripts, workflows, ServiceNow processes, or by user actions such as:

Impersonating a user
Logging in
Viewing a record
Modifying a record

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

Each event is an entry in an event queue and not an action. Unless logic is created to respond to events, nothing happens with an event after it is generated. Responses can be:

___ ___
___ ___ (server-side script)

A

Each event is an entry in an event queue and not an action. Unless logic is created to respond to events, nothing happens with an event after it is generated. Responses can be:

Email notification
Script Action (server-side script)

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

The generalized process to work with events is:

_____
_____
_____

A

The generalized process to work with events is:

Add event to the Event Registry (not needed if you generate an already registered event).
Generate the event.
Respond to the event.

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

There are two ways to generate events:

_____
_____

A

There are two ways to generate events:

Server-side script
Workflow Create Event activity

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

The ___ and ___ methods are part of the GlideSystem server-side API. Use the ___ and ___ methods to generate events in server-side scripts.

A

The eventQueue() and eventQueueScheduled() methods are part of the GlideSystem server-side API. Use the eventQueue() and eventQueueScheduled() methods to generate events in server-side scripts.

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

The eventQueue() method inserts an event in an event queue. The eventQueue() method is typically passed four parameters but can also take an optional 5th parameter:

A

The eventQueue() method inserts an event in an event queue. The eventQueue() method is typically passed four parameters but can also take an optional 5th parameter:

Event name. Enclose the event name in quotes.
GlideRecord object, typically current but can be any GlideRecord object from the event’s table.
Any value that resolves to a string. This is known as parm1 (Parameter 1). Can be a string, variable that resolves to a string, or method that resolves to a string.
Any value that resolves to a string. This is known as parm2 (Parameter 2). Can be a string, variable that resolves to a string, or method that resolves to a string.
(Optional) Name of the queue to manage the event.

17
Q

The logic that responds to an event has access to the passed in GlideRecord object, parm1, and parm2.

Consider this case:

gs.eventQueue(‘x_60157_employee_spe.employeeOccasion’,current,current.number,gs.getUserName());

Why would current.number be passed when current is already included as the record parameter?

A

The logic that responds to an event has access to the passed in GlideRecord object, parm1, and parm2.

Consider this case:

gs.eventQueue(‘x_60157_employee_spe.employeeOccasion’,current,current.number,gs.getUserName());

Notice that the gs.eventQueue method is passed the current object and that parm1 is current.number. Since current was passed as part of the event, passing current.number in parm1 seems redundant. Why, then, would one do this? The parm1 and parm2 parameters appear in their resolved form in the Event Log. Having access to a record identifier, such as the record number, in the logging information can be useful for troubleshooting.

18
Q

DEVELOPER TIP: Use ___ and ___ for parm1 and parm2 if no other values are required to see which user triggered the event in the event log.

A

DEVELOPER TIP: Use gs.getUserName() and gs.getUserID() for parm1 and parm2 if no other values are required to see which user triggered the event in the event log.

19
Q

When would one use the GlideSystem eventQueueScheduled() method instead of gs.eventQueue

A

Use the GlideSystem eventQueueScheduled() method to generate an event with an expiration.

20
Q

What is being displayed below:

Created: Date and time of the event for the locale of the machine running the ServiceNow instance.
Name: Name of the event.
Parm1: Value passed when the event was generated.
Parm2: Value passed when the event was generated.
Table: Database table acted on by this event.
Processed: Date and time the event was processed. This time reflects the locale of the machine running the ServiceNow instance.
Processing duration: Time taken to process this event in milliseconds.
Queue: Processor queue name.

A

These are the values that can be seen in the event log

21
Q

There are two possible ways to respond to events:

A

There are two possible ways to respond to events:

Email Notification
Script Action

Script Actions are event handlers; server-side script logic that executes in response to events.

22
Q

Script actions have two scripting fields:
___
___

Script actions can access two useful objects:
___
___

A

Script actions have two scripting fields:

Condition Script: JavaScript condition for Script to execute. The Script only loads if the condition tests true.
Script: Server side JavaScript logic to execute if the condition tests true.

Script actions can access two useful objects:

event
current

23
Q

The Script field, but not the Condition field, has access to the ___ ___. To use parm1 or parm2, reference them as properties on the ___ ___.

A

The Script field, but not the Condition field, has access to the event object. To use parm1 or parm2, reference them as properties on the event object:

if(event.parm2 != ‘admin’){ }

24
Q

What would be the purpose of a custom event queue?

A

Applications that create a large volume of events and/or events that take a long time to process should use a custom queue.

Populate the Queue field for the event in the Event Registry to define a custom queue. Use only lowercase letters, no spaces, and no special characters except underscore (_).

25
Q

QUESTION: Which one of the following is NOT a true statement Scheduled Script Executions?
1. Automated server-side script logic
2. Execute at a specific time or on a recurring basis
3. Can be executed on demand
4. Executes once per month
5. Typically used for time-based application processes

A

QUESTION: Which one of the following is NOT a true statement Scheduled Script Executions?
1. Automated server-side script logic
2. Execute at a specific time or on a recurring basis
3. Can be executed on demand
4. Executes once per month
5. Typically used for time-based application processes

ANSWER: Response 4 is not a true statement. Although a Scheduled Script Execution can be configured to execute once per month, it is not required. Scheduled Script Executions can be configured to run weekly, for example.

26
Q

QUESTION: Which one of the following is NOT a frequency for the Run field of a Scheduled Script Execution?
1. Daily
2. Weekly
3. Monthly
4. Annually
5. Periodically

A

QUESTION: Which one of the following is NOT a frequency for the Run field of a Scheduled Script Execution?
Daily
Weekly
Monthly
Annually
Periodically
ANSWER: Response 4 is not a true statement.

27
Q

QUESTION: Which of the following are true statements for Scheduled Script Execution scripts? More than one response may be correct.
1. Execute server-side
2. Do not have access to the current or previous objects
3. Variables in the Condition script field are not known in the Run this script field
4. If there is no Condition script, the Condition field returns false
5. The Condition script field must set the answer variable to true or false

A

QUESTION: Which of the following are true statements for Scheduled Script Execution scripts? More than one response may be correct.
1. Execute server-side
2. Do not have access to the current or previous objects
3. Variables in the Condition script field are not known in the Run this script field
4. If there is no Condition script, the Condition field returns false
5. The Condition script field must set the answer variable to true or false
ANSWER: The correct responses are 1, 2, and 5. Variables in the Condition script field are known to the Run this script field if the rules of JavaScript scope allow it. If there is no Condition script, the Condition field returns true.

28
Q

QUESTION: Which one of the following correctly describes how a Scheduled Script Execution is configured to run on the last day of the month?
1. Create a daily Scheduled Script Execution and use the Condition Builder to select Last day of month
2. Create a daily Scheduled Script Execution and use the Condition Builder to create the condition 28 || 29 || 30 || 31
3. Create a monthly Scheduled Script Execution and set the Day to 31
4. Create a monthly Scheduled Script Execution and set the Day to 28
5. Scheduled Script Executions cannot be configured to run on the last day of the month

A

QUESTION: Which one of the following correctly describes how a Scheduled Script Execution is configured to run on the last day of the month?
1. Create a daily Scheduled Script Execution and use the Condition Builder to select Last day of month
2. Create a daily Scheduled Script Execution and use the Condition Builder to create the condition 28 || 29 || 30 || 31
3. Create a monthly Scheduled Script Execution and set the Day to 31
4. Create a monthly Scheduled Script Execution and set the Day to 28
5. Scheduled Script Executions cannot be configured to run on the last day of the month
ANSWER: The correct response is 3.

29
Q

QUESTION: Use the Today’s Scheduled Jobs module to see which Scheduled Script Executions will execute today. Which one of the following is NOT a column in the Today’s Scheduled Jobs list?
1. Name
2. Next action
3. Last action
4. Trigger type
5. State

A

QUESTION: Use the Today’s Scheduled Jobs module to see which Scheduled Script Executions will execute today. Which one of the following is NOT a column in the Today’s Scheduled Jobs list?
1. Name
2. Next action
3. Last action
4. Trigger type
5. State
ANSWER: Response 3 is the correct response. The Today’s Scheduled Jobs table does not have a Last action column.

30
Q

QUESTION: Which of the following are steps in the generalized process for working with events? More than one response may be correct.
1. Add an event to the Event Registry
2. Write a Business Rule
3. Generate the event
4. Respond to the event
5. Create a Scheduled Script Execution

A

QUESTION: Which of the following are steps in the generalized process for working with events? More than one response may be correct.
1. Add an event to the Event Registry
2. Write a Business Rule
3. Generate the event
4. Respond to the event
5. Create a Scheduled Script Execution
ANSWER: The correct responses are 1, 3, and 4. Although you could use a Business Rule or Scheduled Script Execution to generate the event, any server-side script can do that. Business Rules and Scheduled Script Executions are not part of the generalized process for working with events.

31
Q

QUESTION: Which one of the following best describes the Event Registry?
1. List of all events executed today
2. Used to generate events
3. The queue manager to determine order of event processing
4. Allows ServiceNow processes to recognize and respond to events
5. An event debugger

A

QUESTION: Which one of the following best describes the Event Registry?
1. List of all events executed today
2. Used to generate events
3. The queue manager to determine order of event processing
4. Allows ServiceNow processes to recognize and respond to events
5. An event debugger
ANSWER: Response 4 is the correct response.

32
Q

QUESTION: Which of the following are ways to generate an event in ServiceNow? More than one response may be correct.
1. Create Event workflow activity
2. gs.eventQueueScheduled() method in a client-side script
3. gs.eventQueue() method in a client-side script
4. gs.eventQueueScheduled() method in a server-side script
5. gs.eventQueue() method in a server-side script

A

QUESTION: Which of the following are ways to generate an event in ServiceNow? More than one response may be correct.
1. Create Event workflow activity
2. gs.eventQueueScheduled() method in a client-side script
3. gs.eventQueue() method in a client-side script
4. gs.eventQueueScheduled() method in a server-side script
5. gs.eventQueue() method in a server-side script
ANSWER: The correct responses are 1, 4 and 5. The methods for generating events, gs.eventQueue() and gs.eventQueueScheduled() are server-side methods and not client-side.

33
Q

QUESTION: Which one of the following is NOT passed as a parameter to the gs.eventQueue() method when generating an event?
1. Event name
2. User
3. parm1
4. parm2
5. GlideRecord object

A

QUESTION: Which one of the following is NOT passed as a parameter to the gs.eventQueue() method when generating an event?
1. Event name
2. User
3. parm1
4. parm2
5. GlideRecord object
ANSWER: The correct response is 2. The gs.eventQueue() method does not include passing a User or User information as a parameter. Developers may choose to pass User information in parm1, parm2, or as part of the GlideRecord object but it is not required.

34
Q

QUESTION: Which of the following are true statements about the Event Log? More than one response may be correct.
1. Shows which events have been generated
2. Displays the runtime values of Parm1 and Parm2
3. Shows Processing duration in seconds
4. Allows developers to determine which queue processed the event
5. Shows which table the GlideRecord object passed to the event is part of

A

QUESTION: Which of the following are true statements about the Event Log? More than one response may be correct.
1. Shows which events have been generated
2. Displays the runtime values of Parm1 and Parm2
3. Shows Processing duration in seconds
4. Allows developers to determine which queue processed the event
5. Shows which table the GlideRecord object passed to the event is part of
ANSWER: The correct responses are 1, 2, 4, and 5. The Event Log does show processing duration but the values are in milliseconds and not in seconds.

35
Q

QUESTION: Which of the following are possible ways to respond to events? More than one response may be correct.
1. Email Notification
2. Business Rule
3. Scheduled Script Execution
4. Respond Event workflow activity
5. Script Action

A

QUESTION: Which of the following are possible ways to respond to events? More than one response may be correct.
1. Email Notification
2. Business Rule
3. Scheduled Script Execution
4. Respond Event workflow activity
5. Script Action
ANSWER: The correct responses are 1 and 5.