---
sourceDocument: Xanadu ServiceNow AI Platform Administration
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/platform-administration

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu ServiceNow AI Platform Administration

ft:clusterId :

    - platadm

bundleId :

    - platadm

workflow :

    - Platform


---

# Create an event

# Create an event {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 2 minutes to read

If you do not find a suitable existing event, you can create your own.

## Before you begin

Role required: admin

## About this task

The gs.EventQueue function works directly with the backend and therefore business rules that are called by gs.EventQueue() are not invoked.

## Procedure

1. Navigate to AllSystem PolicyEventsRegistry, and then select New.
2. On the form fill in the fields.  
   {#t_CreateYourOwnEvent__table_hbv_pg3_j1c__entry__2}

   | Field | Description |
   |-|-|
   | Event name | Name of your new event. |
   | Table | Database table for this event. Note: Only tables and database views that are in the same scope as the event appear on the listing. |
   | Queue | Name of the queue that the event is placed into when triggered. Use only lowercase letters, no spaces, and no special characters except underscore (_). For example, <kbd class="ph userinput">my_queue</kbd>. See [Using custom queues to process events](https://www.servicenow.com/docs/access?context=useful-server-side-scripts&version=xanadu&pubname=xanadu-application-development&section=queues-create&ft:locale=en-US). |
   | Priority | Order in which messages will be processed. Lower values have higher priority. Note: The com.glide.sysevent.priority.enabled system property is enabled by default. If you disable it, events processing is not done by priority. |
   | Caller Access | Restricted caller access settings. * Caller Restriction: calls to the resource must be manually approved. * Caller Tracking: Calls to the resource are automatically approved. {#t_CreateYourOwnEvent__ul_jtv_233_j1c} |
   | Fired by | Name of the business rule that runs the event. This field is for reference only and is not used by any process. Make sure that there is enough information to locate your event again. |
   | Description | Short description of the purpose of the event. |
   [Table 1. Event Registration Form Completion]

   {#t_CreateYourOwnEvent__table_hbv_pg3_j1c}
3. Click the Business Rules related link.
4. If you are creating an event for a base system table, select the existing event business rule for the table.  
   For example, select the sc request events business rule to create a custom Request event.
5. If you are updating an existing event business rule, add a new condition to the Script.  
   The following sample script adds a request.commented event with the user's Sys ID as parm1 and the user's user name for parm2.

       if (current.operation() != 'insert' && current.comments.changes()) {
       gs.eventQueue('request.commented', current, gs.getUserID(), gs.getUserName());
       }

6. If you are creating an event for a custom table, create a new business rule that runs after database operations.  
   For example, this business rule defines several events for a custom application called Marketing Events.  
   {#t_CreateYourOwnEvent__table_st1_hzs_wy__entry__2}

   | Field | Value |
   |-|-|
   | Name | Attendee Events |
   | Table | Attendee \[x_snc_marketing_ev_attendee\] |
   | Application | Marketing Events |
   | Advanced | Selected |
   | When | after |
   | Insert | Selected |
   | Update | Selected |
   | Delete | Selected |
   | Script | Add custom script that: * Checks for one or more conditions on the current record. * Calls the gs.eventQueue() method and specifies an event name. {#t_CreateYourOwnEvent__ul_q5m_qvs_wy} See code sample. |
   [Table 2. Sample event business rule]

   {#t_CreateYourOwnEvent__table_st1_hzs_wy}  
   Note:  
   If you add Filter Conditions, Role conditions, or a Condition value, verify it runs the business rule when expected.

       (function executeRule(current, previous /*null when async*/) {
          //This function will be automatically called when this rule is processed.
               //Add event when attendee inserted
               if(current.operation() == 'insert' && current.marketing_event.changes()) {
                       gs.eventQueue('x_snc_marketing_ev.attendee.added', current,
       current.marketing_event, current.email);
               }
               //Add event when marketing event changes
               if(current.operation() == 'update' && current.marketing_event.changes()) {
                       gs.eventQueue('x_snc_marketing_ev.attendee.deleted', previous,
       previous.marketing_event, previous.email);
                       gs.eventQueue('x_snc_marketing_ev.attendee.added', current,
       current.marketing_event, current.email);
               }
               //Add event when attendee deleted
               if(current.operation() == 'delete') {
                       gs.eventQueue('x_snc_marketing_ev.attendee.deleted', current,
                     current.marketing_event, current.email);
       }
       })(current, previous);

7. Register the event.

## What to do next

Create a script action or notification to process the event.
**Related tasks**   

* [Register an event](https://servicenow-prod.fluidtopics.net/LtPPwGUlzb5uFHC6AbTGSg "You can register an event for a specific table and a business rule that fires the event.")  
**Related reference**   

* [Script actions](https://servicenow-prod.fluidtopics.net/8GVfGAxBZUi1xncg5yJ1xQ "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.")

*[\>]: and then


