Business Rule - Event

Rooma1
Tera Contributor

Hi All,

I have been interviewed with a question - "How can we call an event in a business rule".

I answered the syntax: gs.eventQueue('EventName", current, parm1, parm2)

 

Then there was a cross question, what is the role of current here and can we use the another object here?

 

Thanks,

Rooma

4 REPLIES 4

Anand Kumar P
Giga Patron
Giga Patron

Hi @Rooma1 ,

 

IMG_2742.jpeg

 

  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.

 

Mark it as helpful and solution proposed if it serves your purpose.
Thanks,
Anand

abirakundu23
Mega Sage

Hi @Rooma1 ,

 

gs.eventQueue("<event_name>", object, parm1, parm2);
gs.eventQueue('incident.updated', current, gs.getUserID(), gs.getUserName());

The 'current' object is the Glide Record object of the row currently being inserted, updated, deleted, or queried.

We can use 'Previous', 'Current' or 'Glide Record' object.

Please find in detail:

Step 3: Create a Script to Generate the Event · ServiceNow1 (gitbooks.io)
Please mark Helpful & Accept the answer if worth for you.

Maddysunil
Kilo Sage

@Rooma1 

In the context of a business rule, current represents the GlideRecord object of the record that triggered the business rule. This means that current provides access to the data and context of the specific record that initiated the rule. By passing current as a parameter to gs.eventQueue()

 

Now coming to the cross question whether we can use another object:

different GlideRecord object instead of current in the gs.eventQueue() function, it's not a common practice in the context of a business rule. The reason for this is that current is specifically designed to represent the record that triggered the business rule

 

Please Mark Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.

Thanks

 

Sandeepk4624386
Tera Contributor

gs.eventQueue("event_name", current.Object,'Parm1','Parm2'

)