Access to event 'x_12954_events_for_attendee.deleted' from scope 'Marketing Events Application' has been refused. The event is not defined.

sachingawas
Kilo Expert

Access to event 'x_12954_events_for_attendee.deleted' from scope 'Marketing Events Application' has been refused. The event is not defined.

8 REPLIES 8

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Sachin,



Looks like the event you are calling doesn't exists on the system. Can you please check for the same once and let me know if you are blocked.


edbailey
Giga Contributor

Hi



I'm wondering if you ever found the answer to this problem? I am also trying to complete the 'Coding on SN' module in Learn and have the same error.



I've checked the business rule scripting to ensure that the table and field references are correct and also the events registry and it all seems to make sense



Also the business rule must be running or it wouldn't throw the error.



The only thing that appears undefined in the event registry is the queue.



Event reg.JPG


Having read the following article on common errors it suggests that the error is generated because the "event name that is missing the application namespace prefix"



I've checked the business rule and it has namespace prefix. Would referencing the wrong table have the same effect. Here's my business rule which has the prefix.



function onAfter(current, previous) {


    //This function will be automatically called when this rule is processed.


  //Add event when attendee inserted


  if(current.operation() == 'insert' && current.marketing_event.changes()) {


  gs.eventQueue('x_11499_marketing_marketing_event.attendee.added', current,


current.marketing_event, current.email);


  }


  //Add event when marketing event changes


  if(current.operation() == 'update' && current.marketing_event.changes()) {


  gs.eventQueue('x_11499_marketing_marketing_event.attendee.deleted', previous,


previous.marketing_event, previous.email);


  gs.eventQueue('x_11499_marketing_marketing_event.attendee.added', current,


current.marketing_event, current.email);


  }


  //Add event when attendee deleted


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


  gs.eventQueue('x_11499_marketing_marketing_event.attendee.deleted', current,


                          current.marketing_event, current.email);


}


}



The other idea I have is that the business rule is referencing the wrong table (marketing events rather than attendee) but I've tried changing this to no effect


I've finally worked it out.



The   business rule scrip should be



function onAfter(current, previous) {


    //This function will be automatically called when this rule is processed.


  //Add event when attendee inserted


  if(current.operation() == 'insert' && current.marketing_event.changes()) {


  gs.eventQueue('x_11499_marketing.attendee.added', current,


current.marketing_event, current.email);


  }


  //Add event when marketing event changes


  if(current.operation() == 'update' && current.marketing_event.changes()) {


  gs.eventQueue('x_11499_marketing.attendee.deleted', previous,


previous.marketing_event, previous.email);


  gs.eventQueue('x_11499_marketing.attendee.added', current,


current.marketing_event, current.email);


  }


  //Add event when attendee deleted


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


  gs.eventQueue('x_11499_marketing.attendee.deleted', current,


                          current.marketing_event, current.email);


}


}




I think its all down the confusion caused by being instructed to rename marketing to marketing event   or marketing ev depending on which sections of Learn you have completed.