---
sourceDocument: Australia API Reference
sourceDocumentLink: https://www.servicenow.com/docs/r/api-reference

 Release :

    - australia

ft:locale :

    - en-US

ft:publication_title :

    - Australia API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# Scripting messages

# Scripting alert, info, and error messages {#ariaid-title1}

* Release version: Australia
* 
* Updated March 12, 2026
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 1 minute to read

You can send messages to customers as alerts, informational messages, or error
messages.
{#r_ScriptingAlertInfoAndErrorMsgs__table_i1c_k2m_jp__entry__2}

| Script | Result |
|-|-|
| `current.field_name.setError("Hello World"); ` | Adds Hello World below the specified field in a red error message. |
| `gs.addInfoMessage("Hello World"); ` | Adds Hello World at the top of the browser window in a blue info message. |
| `gs.addErrorMessage("Hello World"); ` | Adds Hello World at the top of the browser window in a red error message. |
| `gs.print("Hello World");` | Writes <kbd class="ph userinput">Hello World</kbd> to the text log on the file system but not to the sys_log table in the database. |
| `gs.log("Hello World"); ` | Writes <kbd class="ph userinput">Hello World</kbd> to the database and the log file. Note: gs.log can adversely affect performance if used too frequently. |
[Table 1. Business rule and other general use scripts]

{#r_ScriptingAlertInfoAndErrorMsgs__table_i1c_k2m_jp} {#r_ScriptingAlertInfoAndErrorMsgs__table_wbp_cfm_jp__entry__2}

| Script | Result |
|-|-|
| `alert("Hello World"); ` | 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://www.servicenow.com/docs/AvGpQi3FLDsnTZadXSevSQ#r_DisplayFieldMessages "Rather than use JavaScript alert(), for a cleaner look, you can display an error on the form itself. The methods showFieldMsg() and hideFieldMsg() can be used to display a message just below the field itself."). |
| `confirm("Hello World");` | Displays a window with Hello World? and OK and Cancel buttons. |
| `g_form.showFieldMsg("field_name", "Hello World", "error");` | Adds Hello World below the specified field in a red error message. |
| `g_form.hideFieldMsg("field_name");` | Hides the most recent message for the specified field. |
[Table 2. Client side scripts]

{#r_ScriptingAlertInfoAndErrorMsgs__table_wbp_cfm_jp}  
Important:  
The methods in this table are only for use in client scripts.It is also possible to add other custom messages to your forms if necessary using client scripting. The text size of info and error messages at the top of the screen is customizable. Two
properties control this. If you
configured
your forms, you may need to add these properties.  
Note:  
The client script alert option is not available for use with Automated Test Framework (ATF).
{#r_ScriptingAlertInfoAndErrorMsgs__table_kcn_ggm_jp__entry__2}

| 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. |
[Table 3. Error and alert text size properties]

{#r_ScriptingAlertInfoAndErrorMsgs__table_kcn_ggm_jp}

