Help with event parameters when changing table where event is generated

jlaps
Kilo Sage

We have a notification that is triggered on with an event from the sys_user table. The notification is configured for using the sys_user table. I have developed another table where I am collecting the required information before triggering the event, so the user record (and user id and user name) was passed in the event parameters as below-

if (current.operation() == 'insert') {

	gs.eventQueue("Onboard.Facilities.Team", current, gs.getUserID(), gs.getUserName());
	gs.eventQueue("new.employee/Contingent.worker.onboard", current, gs.getUserID(), gs.getUserName());
//	gs.eventQueue("cei_new.employee/Contingent.onboard", current, gs.getUserID(), gs.getUserName());
}

I have a new table now where I am insuring we have all the data first to avoid sending the notification with missing fields, but I am trying to avoid having to reconfigure the notification which is configured for sys_user, so I am  trying to pass the parameters correctly, but am not getting it right. Below is my most recent attempt, hoping for some help on doing it correctly!

 

	gs.eventQueue("Onboard.Facilities.Team", current.u_employee, current.u_employee.gs.getUserID(), current.u_employee.gs.getUserName());
	gs.eventQueue("new.employee/Contingent.worker.onboard", current.u_employee, current.u_employee.gs.getUserID(), current.u_employee.gs.getUserName());
	current.u_onboard_email_sent = true;
//	gs.eventQueue("cei_new.employee/Contingent.onboard", current, gs.getUserID(), gs.getUserName());

The user record I am trying to pass is the reference field u_employee now on a new table. How can I configure the parameters so it passes the needed info so I do not have to change the notification table?

3 REPLIES 3

LorenzVdV
Giga Guru

Your second parameter needs to be gs.getUser().getUserByID(current.employee)

 

This will get the sys_user gliderecord object of the value in the u_employee field. The second parameter of gs.eventQueue needs to be a GlideRecord.

 

current.employee just holds the sys-id of the employee you are referencing, it's not a GlideRecord.

 

(Because in this use case you want to end up with a sys_user GlideRecord, you can use the User object function as I did. If in the future you want to write events for other tables, you'll need to work with a GlideRecord query to get to the GlideRecord you need.)

Thank you, giving this a try...

Just noticed now that your other parameters are also a bit of a mess.

Third parameter can be current.getValue('u_employee')

Last parameter can be current.u_employee.getValue('user_name')