Helix Core is now P4. Product user interfaces will be updated soon. Learn more >>

P4V API for JavaScript Documentation | 2025.4

# Example for P4 Admin - HTML Alert

Alerts in P4 Admin have a small API as shown in the P4 Admin Alert API section below. This API is also shown in the code example, which is installed by default at:

- <P4VJS Directory>\examples\p4admin\DemonstrationAlert.js for Windows
- <P4VJS Directory>/examples/p4admin/DemonstrationAlert.js for Linux and Mac

To write the logic of your alert, you can also use the Supported functions of P4VJS.

To run the example of an HTML Alert for P4 Admin:

1. Make sure that HTML tools are enabled in your P4 Admin preferences.
2. Know the absolute path to the file with the DemonstrationAlert.js code.
3. On the Tools menu, select Manage Tools > HTML Alerts...
4. In the Manage HTML Alerts dialog, click New.
5. Configure the example by assigning a Name, setting the URL field to the absolute path of the example, and setting the Entry Point to Change.runAlert.

   When you write your own custom Alerts, the value of the URL field can be a web address or an absolute path to a file.

6. Save your Alert.
7. In Home, right-click the Alerts box and select Reload on the context-menu.
8. Notice that the Alert has posted a message.

## P4 Admin Alert API

What follows is the API that is available exclusively for P4 Admin Alerts.

### AlertAPI.addAlert(msg, status) [async]

Posts a new alert to the alerts box and returns the identifier.

msg: The message text for your alert.

status: The status level of your alert. By default it is AlertAPI.Status.Warning.

return value: An identifier of the posted alert. You can save this to use on your next pass.

### AlertAPI.updateAlert(id, msg, status) [async]

Updates a posted alert.

id: The identifier of the alert to modify.

msg: The message text for your alert.

status: The status level of your alert. By default it is AlertAPI.Status.Warning.

return value: none.

### AlertAPI.deleteAlert(id) [async]

Removes a posted alert from the alerts box.

id: The identifier of the alert to delete.

return value: none.

### AlertAPI.Status levels

There are three alert status levels you can use, each of which has its own icon:

- Info
- Error
- Warning

## Appending to the list of alerts

When a new alert occurs, it is appended to the list of alerts.

Let's start with this code :

    var AlertId1 = AlertAPI.addAlert("Posting Alert 1", AlertAPI.Status.Info );
    var AlertId2 = AlertAPI.addAlert("Posting Alert 2", AlertAPI.Status.Info );
    var AlertId3 = AlertAPI.addAlert("Posting Alert 3", AlertAPI.Status.Info );

A new alert is appended to the end of the list, so the position order is :

1: Posting Alert 1

2: Posting Alert 2

3: Posting Alert 3

Let's now update one of the alerts.

AlertAPI.updateAlert(AlertId2, "Updating Alert2", AlertAPI.Status.Warning );

If you start up p4admin with existing Alerts, they automatically load and display.

After adding a new Alert or changing the code in an Alert, to display the addition or change, right-click the Alerts box and select Reload on the context-menu.

An update does not change the position of the previously posted alert, so the position order remains :

1: Posting Alert 1

2: Updating Alert2

3: Posting Alert 3

Now let's delete an alert:

AlertAPI.deleteAlert(AlertId1);

The position order is now:

1: Updating Alert2

2: Posting Alert 3

Your search for returned results