Please use docs.servicenow.com for the latest documentation.

This site is for reference purposes only and may not be accurate for the latest ServiceNow version

Script Actions

From Wiki Archive
Jump to: navigation, search
Note
Note: This article applies to Fuji and earlier releases. For more current information, see Script Actions at http://docs.servicenow.com

The ServiceNow Wiki is no longer being updated. Visit http://docs.servicenow.com for the latest product documentation.


{{Topic|Scripting Glide and Jelly

Overview

You can use Script Actions to create server-side scripts that perform a variety of tasks, such as modifying a configuration item (CI), or managing failed login attempts. Script actions are triggered by events only.

Configuration

To create a new script action, navigate to System Policy > Events > Script Actions and click New.

Field Input Value
Name
Type a unique name for your script action.
Event name
Select the event to use for this script. If you do not find an event for your script action that suits your purpose, you can create a new one in Business Rules.
Application
The application that contains this script. This field is available starting with the Fuji release.
Order
The order in which the script will be executed.
Active
Select the check box (true) to enable this script action.
Condition script Create a statement for a condition under which this script should execute. By adding the condition statement to this field, you tell ServiceNow to evaluate the condition separately and parse the script only if the condition is true. If you decide to include the condition statement in the script, leave this field blank.
Script Create a script that runs when the condition you define evaluates to true. Two additional objects are available in this script:
  • event: a GlideRecord - the sysevent that caused this to be invoked. If you wanted so get this first parameter on the event, you would use event.parm1 or event.parm2 for the second parameter. For the date/time of the event, use event.sys_created_on. To get the user ID that created the event (if there was a user associated), use event.user_id.
  • current: a GlideRecord - the event scheduled on behalf of (incident for example).


This is a sample of a script action that creates an email notification for Workflow activity:


Error creating thumbnail: Unable to save thumbnail to destination

Attachment Logging

Whenever a user downloads an attachment, the action writes an attachment.read event record to the event log. If desired, you can process these events with a Script Action or an Email Notification. This can be useful if you want to do something when an attachment is read. For example, you can record when and by whom certain attachments are downloaded. For this functionality, the current variable must point to a sys_attachment record, and the event record must use the following parameters:

  • parm1: File name
  • parm2: Table name