Doubt using business rule how can we apply this gs.eventQueue() method in incident table

Community Alums
Not applicable

Hi all

 

eventQueue(String name, Object glideRecord, String parm1, String parm2, String queue)

can you please any one help me with some simple scenario if it is possible.

 

Thanks 

Jyothinath

1 ACCEPTED SOLUTION

K Akhila
Kilo Guru

Hi Jyothinatha,

 

There are two ways to generate events:

  • Server-side script using the gs.eventQueue() method
  • Workflow Create Event activity

gs.eventQueue() Method

The eventQueue() method is part of the GlideSystem server-side API. The eventQueue() method inserts an event in an event queue. The eventQueue() method is typically passed four parameters but can also take an optional 5th parameter:

  1. Event name. Enclose the event name in quotes.
  2. GlideRecord object, typically current but can be any GlideRecord object from the event's table.
  3. Any value that resolves to a string. This is known as parm1 (Parameter 1). Can be a string, variable that resolves to a string, or method that resolves to a string.
  4. Any value that resolves to a string. This is known as parm2 (Parameter 2). Can be a string, variable that resolves to a string, or method that resolves to a string.
  5. (Optional) Name of the queue to manage the event.

example:

gs.eventQueue('event.name', GlideRecord, parm1, parm2); // standard form

gs.eventQueue('x_58872_needit.overdueNeedItTask',current,current.number,gs.getUserName());

 

eventQueue(String name, Object glideRecord, String parm1, String parm2, String queue)

Parameter(s):

Name Type Description
nameStringName of the event being queued.
glideRecordObjectGlideRecord object, such as "current".
parm1String(Optional) Saved with the instance if specified.
parm2String(Optional) Saved with the instance if specified.
queueStringName of the queue.

 

The first parameter is the event name and this is defined in the event-> Registry.

 

Please mark your response as helpful or correct.

Thanks

View solution in original post

3 REPLIES 3

darren_halliday
ServiceNow Employee
ServiceNow Employee

Hi there.

Here are a couple of scenarios: - the code writes to the Event table and event (e.g. incident.commented, incident.assigned).  Parm1 and Parm2 can include extra data about the event (e.g. sysid of the assignee, incident caller sysid)

(i) Logging - There is a business rule baseline called "incident events".  The business rule runs after a change has occurred and writes that change data to the Events table (e.g. work_notes updated, state change...).

(ii) Events can be used as triggers for Notifications.  So for example, the event incident.assigned can be used to trigger a Notification to the assignee.

(iii) Script Actions are triggered by Events.  So you might want the Script Action to trigger when an Incident is created (e.g. incident.inserted) and fire a integration, subflow or some other business logic.

K Akhila
Kilo Guru

Hi Jyothinatha,

 

There are two ways to generate events:

  • Server-side script using the gs.eventQueue() method
  • Workflow Create Event activity

gs.eventQueue() Method

The eventQueue() method is part of the GlideSystem server-side API. The eventQueue() method inserts an event in an event queue. The eventQueue() method is typically passed four parameters but can also take an optional 5th parameter:

  1. Event name. Enclose the event name in quotes.
  2. GlideRecord object, typically current but can be any GlideRecord object from the event's table.
  3. Any value that resolves to a string. This is known as parm1 (Parameter 1). Can be a string, variable that resolves to a string, or method that resolves to a string.
  4. Any value that resolves to a string. This is known as parm2 (Parameter 2). Can be a string, variable that resolves to a string, or method that resolves to a string.
  5. (Optional) Name of the queue to manage the event.

example:

gs.eventQueue('event.name', GlideRecord, parm1, parm2); // standard form

gs.eventQueue('x_58872_needit.overdueNeedItTask',current,current.number,gs.getUserName());

 

eventQueue(String name, Object glideRecord, String parm1, String parm2, String queue)

Parameter(s):

Name Type Description
nameStringName of the event being queued.
glideRecordObjectGlideRecord object, such as "current".
parm1String(Optional) Saved with the instance if specified.
parm2String(Optional) Saved with the instance if specified.
queueStringName of the queue.

 

The first parameter is the event name and this is defined in the event-> Registry.

 

Please mark your response as helpful or correct.

Thanks

Community Alums
Not applicable

Really Thanks For The Information K Akhila.