how to access the object(current) from eventqueue

amala2
Mega Guru

I have an eventqueue : gs.eventQueue("test",current,current); which is triggered via Business Rules.After which in a script action I am getting the parameters of event .So if I try to print the event.parm1 in script action ,I get [object GlideRecord].But after that If I try to get any field from the object ,I am getting "undefined".

My exact requirement is after passing the event.parm1 to script action ,I will call a script include in which I am accessing this object.

eg: gs.eventQueue("test",current,current);--->Business Rule

Script action         :

        var si= new testingnow(event.parm1);

        si.myfun();

Script include:

initialize: function(record) {

  this.record = record;

}

     

7 REPLIES 7

mrswann
Kilo Guru

Once written to the event Parms its just a string so you need to work it in to any subsequent logic accordingly. Usually with a glide record query to make it useful , I think there may be a user object stored in the event but otherwise it's just paper


Thanks for your reply.


I checked the type of event parm & its a object.


ghsrikanth
Tera Guru

This community may give you an idea, how to use event.parm1 -


Re: How to access event.parm1 in mail script?



Mark if it is correct or helpful, feedback is appreciated


tony_barratt
ServiceNow Employee
ServiceNow Employee

Hi Amala,


You should review what parameters you are passing to eventQueue()



GlideSystem - ServiceNow Wiki


..


3.1 eventQueue(String, Object, String, String, String)

Queues an event for the event manager.


3.1.1 Input Fields

Parameters:


  • Name of the event being queued.
  • A GlideRecord object, such as "current".
  • An optional parameter, saved with the instance if specified.
  • A second optional parameter, saved with the instance if specified.
  • An event queue to add the event to.

3.1.2 Example


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


You are calling gs.eventQueue("test",current,current)


So parameters are in order are:


Name of the event being queued = test


A GlideRecord object, such as "current". = current


An optional parameter, saved with the instance if specified. = current



The last mentioned parameter you specify is a glide object, but should be a string - as hinted at by mrswann above.



Best Regards



Tony