I’m so far behind with posting blog ideas that a lot of times when I go back to my list the things that I was excited to blog about previously now seem trivial.
However trivial they may be though, there is likely someone else out there that doesn’t know them yet, so I’ll continue posting them in the hopes that someone can save half an hour debugging because they stumbled across my blog while doing a google search on the topic.
It’s possible (and easy) to create a event from inside of a script. You use gs.eventQueue()
Then you pass the name of the event, a Glide Record object, and the values for the parm 1 and parm 2 on the event.
The tricky part is that my normal method for getting a Glide Record doesn’t work. I normally do something like this:
var gr = new GlideRecord(‘sys_user’);
gr.addQuery(‘sys_id’, ”d3489ac7dbbe8c10c772f9baae9619e8′);
gr.query();
gr.next();
However, passing gr into my gs.eventQueue() call didn’t work. Instead, apparently, you have to use the gr.get() construction.
For instance:
var gr = new GlideRecord(‘sc_req_item’);
gr.get(‘d3489ac7dbbe8c10c77af9baae9619e7’);
gs.eventQueue(‘my.event’, gr, ‘869104dc1b7c7b48ubbd43b3cd4bcb53’, ‘f2b1694edb768010co72f9baae9619c3’ );