Event Access Error when Setting up Attachment Event

dmullinax
Mega Guru

I am trying to set up a trigger email whenever an attachment is added for a custom table using the accepted solution here:

 

https://www.servicenow.com/community/developer-forum/how-to-trigger-mail-whenever-attachment-is-adde...

 

Event Registry:

event_reg.jpg

 

Business Rule:

bus_rule.jpg

Script:

(function executeRule(current, previous /*null when async*/ ) {
    var incObj = new GlideRecord("x_losls_ogac_ogac_table");
    if (incObj.get(current.table_sys_id)) {
        gs.eventQueue("x_losls_ogac_ogac_table.attachment.add", incObj, current.file_name);
    }

})(current, previous);

 

Notification:

notification.jpg

When I add an attachment to the record, I'm getting this error message:

error.jpg

Error MessageAccess to event 'x_losls_ogac_ogac_table.attachment.add' from scope 'OGAC' has been refused. The event is not defined.
Info MessageExecute operation on API 'Glide API: event management' from scope 'OGAC' was granted and added to 'OGAC' cross scope privileges

How do I resolve this?

1 ACCEPTED SOLUTION

Just noticed that you seem to be using the value from the "suffix" field, but you should actually use the "event name", i.e. x_losls_ogac.x_losls_ogac_ogac_table.att.

View solution in original post

5 REPLIES 5

Laszlo Balla
ServiceNow Employee
ServiceNow Employee

The second message actually indicates that a previously missing cross-scope privilege record added after your first attempt. Did you try again since this error? Do you still get the exact same message?

 

All you need is just adding the missing cross-scope privilege record(s).

dmullinax
Mega Guru

Here's the results of the second attempt.  I'm reviewing your link now...

second_attachment.jpg

Just noticed that you seem to be using the value from the "suffix" field, but you should actually use the "event name", i.e. x_losls_ogac.x_losls_ogac_ogac_table.att.

That did it!

(function executeRule(current, previous /*null when async*/ ) {
    var incObj = new GlideRecord("x_losls_ogac_ogac_table");
    if (incObj.get(current.table_sys_id)) {
        gs.eventQueue("x_losls_ogac_ogac_table.attachment.add", incObj, current.file_name);
    }

})(current, previous);