I recently worked on a project where the requirements specified an email address would be used to send from in ServiceNow using the Mail Client– this is easy enough. I then created a return inbound action for the type of reply so external clients could reply to the emails- this was simple too.
A further requirement then came in to stop clients sending in new mail to this address, an auto response in essence- so I did the following:
- Created the inbound action for type of reply pointing to the target table.
- Created an event using GS Event Queue and registered this event, using the sys_id for the parm1.
- Created a notification to fire from this event with content to the parm1 as the recipient.
Each time I tested the inbound action it will trigger the event, but the notification would not fire!
Checking the error logs it seems as I was using “current” in the event, and no current record was ever created- the event would error and the notification would not send.
getEventTarget() called with invalid record reference: u_table_name_here.sys_id_number_was_here for event: event.name, could have been deleted
How I got round this:
By updating the inbound action to point to the “sys_email” table I was able to use the script below to insert a record ready to send an email:
current.type = 'send-ready';
current.recipients = email.origemail;
current.subject = 'The subject of the email goes here.';
current.body = 'HTML content goes here';
This was a great and simple work around to a problem.
Thank you for reading.