Scripting alert, info, and error messages
You can send messages to users as alerts, informational messages, or error messages.
|
Script |
Result |
|---|---|
|
|
Adds |
|
|
Adds |
|
|
Adds |
|
|
Writes |
|
|
Writes |
|
Script |
Result |
|---|---|
|
|
Displays a window with Note: The client script alert option is not available for use with Automated Test Framework (ATF). |
|
|
Displays a window with |
|
|
Adds |
|
|
Hides the most recent message for the specified field. |
| Property | Description |
|---|---|
| css.outputmsg.info.text.font-size | Sets the size for info messages. Default is 11pt. |
| css.outputmsg.error.text.font-size | Sets the size for error messages. Default is 11pt. |
Parent Topic:Exploring scripting
---
title: Scripting alert, info, and error messages
description: You can send messages to users as alerts, informational messages, or error messages.
locale: en-US
canonical_url: https://www.servicenow.com/docs/r/australia/api-reference/scripts/r\_ScriptingAlertInfoAndErrorMsgs.html
release: australia
product: Scripts
classification: scripts
topic_type: reference
last_updated: "2026-09-10"
reading_time_minutes: 1
breadcrumb: [Explore, Scripting, API implementation, API implementation and reference]
---
# Scripting alert, info, and error messages
You can send messages to users as alerts, informational messages, or error messages.
<table id="table_i1c_k2m_jp"><thead><tr><th>
Script
</th><th>
Result
</th></tr></thead><tbody><tr><td>
`current.field_name.setError("Hello World");`
</td><td>
Adds `Hello World` below the specified field in a red error message.
</td></tr><tr><td>
`gs.addInfoMessage("Hello World");`
</td><td>
Adds `Hello World` at the top of the browser window in a blue info message.
</td></tr><tr><td>
`gs.addErrorMessage("Hello World");`
</td><td>
Adds `Hello World` at the top of the browser window in a red error message.
</td></tr><tr><td>
`gs.print("Hello World");`
</td><td>
Writes `Hello World` to the text log on the file system but not to the sys\_log table in the database.
</td></tr><tr><td>
`gs.log("Hello World");`
</td><td>
Writes `Hello World` to the database and the log file.**Note:** gs.log can adversely affect performance if used too frequently.
</td></tr></tbody>
</table><table id="table_wbp_cfm_jp"><thead><tr><th>
Script
</th><th>
Result
</th></tr></thead><tbody><tr><td>
`alert("Hello World");`
</td><td>
Displays a window with `Hello World` and an **OK** button.**Note:** Rather than use JavaScript alert\(\), for a cleaner look, you can display an error on the form itself with thee showFieldMsg\(\) and hideFieldMsg\(\) methods. For more information, see [Display field messages](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/scripts/r_DisplayFieldMessages.md).
**Note:** The client script alert option is not available for use with Automated Test Framework \(ATF\).
</td></tr><tr><td>
`confirm("Hello World");`
</td><td>
Displays a window with `Hello World?` and **OK** and **Cancel** buttons.
</td></tr><tr><td>
`g_form.showFieldMsg("field_name", "Hello World", "error");`
</td><td>
Adds `Hello World` below the specified field in a red error message.
</td></tr><tr><td>
`g_form.hideFieldMsg("field_name");`
</td><td>
Hides the most recent message for the specified field.
</td></tr></tbody>
</table>You can customize the font size of info and error messages at the top of the screen using two system properties.
|Property|Description|
|--------|-----------|
|css.outputmsg.info.text.font-size|Sets the size for info messages. Default is 11pt.|
|css.outputmsg.error.text.font-size|Sets the size for error messages. Default is 11pt.|
**Parent Topic:**[Exploring scripting](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/scripts/c_Script.md)
| title | Scripting alert, info, and error messages |
| description | You can send messages to users as alerts, informational messages, or error messages. |
| locale | en-US |
| canonical_url | https://www.servicenow.com/docs/r/australia/api-reference/scripts/r\_ScriptingAlertInfoAndErrorMsgs.html |
| release | australia |
| product | Scripts |
| classification | scripts |
| topic_type | reference |
| last_updated | 2026-09-10 |
| reading_time_minutes | 1 |
| breadcrumb | ExploreScriptingAPI implementationAPI implementation and reference |