<h2>Script actions</h2><br/><div style="overflow-x:auto"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head><meta content="text/html; charset=UTF-8" /><meta name="copyright" content="(C) Copyright 2025" /><meta name="DC.rights.owner" content="(C) Copyright 2025" /><meta name="generator" content="DITA-OT" /><meta name="DC.type" content="reference" /><meta name="DC.title" content="Script actions" /><meta name="abstract" content="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." /><meta name="description" content="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." /><meta name="DC.subject" content="script actions" /><meta name="keywords" content="script actions" /><meta name="DC.creator" content="ServiceNow" /><meta name="DC.date.created" content="2023-08-03" /><meta name="DC.date.modified" content="2023-08-03" /><meta name="DC.format" content="XHTML" /><meta name="DC.identifier" content="r_ScriptActions" /><link rel="stylesheet" type="text/css" href="../../../CSS/commonltr.css" /><title>Script actions</title></head><body id="r_ScriptActions"> <h1 class="title topictitle1" id="ariaid-title1">Script actions</h1> <div class="body refbody"><p class="shortdesc">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.</p> <div class="section"><h2 class="title sectiontitle">Configuration</h2> <p class="p">To create a new script action, navigate to <span class="ph menucascade"><span class="ph uicontrol">System Policy</span> > <span class="ph uicontrol">Events</span> > <span class="ph uicontrol">Script Actions</span></span> and click <span class="ph uicontrol">New</span>.</p> </div> <div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="r_ScriptActions__simpletable_jt1_x1w_xp" class="table" frame="border" border="1" rules="all"><caption><span class="tablecap"><span class="table--title-label">Table 1. </span></span></caption><colgroup><col style="width:50%" /><col style="width:50%" /></colgroup><thead class="thead" style="text-align:left;"><tr class="row"><th class="entry nocellnorowborder" style="vertical-align:top;" id="d363658e76">Field</th><th class="entry cell-norowborder" style="vertical-align:top;" id="d363658e79">Input Value</th></tr></thead><tbody class="tbody"><tr class="row"><td class="entry nocellnorowborder" style="vertical-align:top;" headers="d363658e76 ">Name</td><td class="entry cell-norowborder" style="vertical-align:top;" headers="d363658e79 "> <p class="p">Type a unique name for your script action.</p> </td></tr><tr class="row"><td class="entry nocellnorowborder" style="vertical-align:top;" headers="d363658e76 ">Application</td><td class="entry cell-norowborder" style="vertical-align:top;" headers="d363658e79 "> <p class="p">The application that contains this script.</p> </td></tr><tr class="row"><td class="entry nocellnorowborder" style="vertical-align:top;" headers="d363658e76 ">Event name</td><td class="entry cell-norowborder" style="vertical-align:top;" headers="d363658e79 "> <p class="p">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.</p> </td></tr><tr class="row"><td class="entry nocellnorowborder" style="vertical-align:top;" headers="d363658e76 ">Active</td><td class="entry cell-norowborder" style="vertical-align:top;" headers="d363658e79 "> <p class="p">Select the check box (true) to enable this script action.</p> </td></tr><tr class="row"><td class="entry nocellnorowborder" style="vertical-align:top;" headers="d363658e76 ">Execution Order</td><td class="entry cell-norowborder" style="vertical-align:top;" headers="d363658e79 "> <p class="p">The order in which the script will be executed.</p> </td></tr><tr class="row"><td class="entry nocellnorowborder" style="vertical-align:top;" headers="d363658e76 ">Condition script</td><td class="entry cell-norowborder" style="vertical-align:top;" headers="d363658e79 "> <p class="p">Create a statement for a condition under which this script should execute. The system only parses the <span class="ph uicontrol">Script</span> field if the condition evaluates to true. If you decide to include the condition statement in the script, leave this field blank.</p> </td></tr><tr class="row"><td class="entry row-nocellborder" style="vertical-align:top;" headers="d363658e76 ">Script</td><td class="entry cellrowborder" style="vertical-align:top;" headers="d363658e79 "> <p class="p">Create a script that runs when the condition you define evaluates to true. Two additional objects are available in this script:</p> <div class="p"><ul class="ul"><li class="li"><span class="keyword apiname">event</span>: a <a class="xref" href="../app-store/dev_portal/API_reference/glideRecordScoped/concept/c_GlideRecordScopedAPI.dita/c_GlideRecordScopedAPI.html" target="_blank" rel="noopener noreferrer">GlideRecord</a> - the sysevent that caused this to be invoked. If you wanted so get this first parameter on the event, you would use <span class="keyword parmname">event.parm1</span> or <span class="keyword parmname">event.parm2</span> for the second parameter. For the date/time of the event, use <span class="keyword parmname">event.sys_created_on</span>. To get the user ID that created the event (if there was a user associated), use <span class="keyword parmname">event.user_id</span>.</li><li class="li"><span class="keyword apiname">current</span>: a <span class="keyword apiname">GlideRecord</span> - the event scheduled on behalf of (incident for example).</li></ul> </div> </td></tr></tbody></table> </div> <div class="section"> <p class="p">This is a sample of a script action that creates an email notification for Workflow activity:</p> <div class="p"><div class="fig fignone" id="r_ScriptActions__fig_ScriptActionWorkflow"><span class="figcap"><span class="fig--title-label">Figure 1. </span>Script action workflow</span> <img class="image" id="r_ScriptActions__image_ScriptActionWorkflow" src="../image/ScriptActionWorkflow.png" alt="" /> </div> </div> </div> </div> </body></html></div>