Event is empty when sending a notification

Jonatan4
Giga Guru

I'm trying to pass an event to an email notification, but it is empty. Can anyone help me solve this?
I have a script include with the following code:

var table = gs.getProperty('searchtables')
	
var checkFields = new GlideRecord(table);
checkFields.query();
		
gs.eventQueue('no_tables', '', checkFields.getClassDisplayValue());

I've checked that "checkFields.getClassDisplayValue()" has a value, which it has.

Then I've a Email Script as follows:

var string = event.parm1;
	
email.setSubject('Table ' + string + ' failed');
template.print(string);

But event.parm1 is then empty. I get the email but without the value from parm1

Does anyone know why?

 

1 ACCEPTED SOLUTION

Got it to work, added gs.getUserID();

 

gs.eventQueue('x_225566_gdpr.no_tables', '', gs.getUserID(), checkFields.getClassDisplayValue());

 

My notification has no table, that's why I wanted to have an empty string... Will try with null as well if that's best practice

View solution in original post

5 REPLIES 5

AbhishekGardade
Giga Sage

You need to pass current or checkFields:

gs.eventQueue('no_tables', checkFields, checkFields.getClassDisplayValue());

Please mark as Correct Answer and Helpful, if applicable.
Thanks!
Abhishek Gardade
Hexaware Technologies

Thank you,
Abhishek Gardade

Tried that as well, got the following error: 

"getEventTarget() called with invalid record reference" , "the record may have been deleted".

Found this KB, https://hi.service-now.com/kb_view.do?sysparm_article=KB0522706 but there's no workaround. 

Do you know a way around this?

can you try passing current if you are using business rule? For Which table have you created event? For which table you have written BR?

Please mark as Correct Answer and Helpful, if applicable.
Thanks!
Abhishek Gardade
Hexaware Technologies

Thank you,
Abhishek Gardade

Yeah you can't use an empty string, if there's no current object you can use null

gs.eventQueue('no_tables', null, checkFields.getClassDisplayValue());