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

Thanks a lot. Your solution fixed the issue.


Thanks Ed. Just to expand on that, the gs.eventQueue method requires the name of the Event Registry (i.e. the Event name). If you go to System Policy > Events > Registry, find the record you created for the tutorial, and the Event name is in the greyed out box (because it was automatically generated). If your event name is x_11499_marketing.attendee.added, then your business rule code should have:



gs.eventQueue('x_11499_marketing.attendee.added', current, current.marketing_event, current.email);




Do the same for deleted.


So here is what fixed it for me ED.



My Script



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_17920_marketingg_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_17920_marketingg_attendee.deleted', previous,


previous.marketing_event, previous.email);


  gs.eventQueue('x_17920_marketingg_attendee.added', current,


current.marketing_event, current.email);


  }


  //Add event when attendee deleted


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


  gs.eventQueue('x_17920_marketingg_attendee.deleted', current,


                          current.marketing_event, current.email);


}


}


---------------------------------------------------------------


In the the above script all I changed was the under scores between marketing and attendee (which I have bolded) to peroids like in your script.   I just clicked update went back and tried it again and no error message.



My Fixed Script



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_17920_marketingg.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_17920_marketingg.attendee.deleted', previous,


previous.marketing_event, previous.email);


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


current.marketing_event, current.email);


  }


  //Add event when attendee deleted


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


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


                          current.marketing_event, current.email);


}


}



----------------------------------



I'm not sure how or why that fixed it when the example does not use periods but underscores, but that did the trick!


swathi10289
Kilo Contributor

function onAfter(current, previous) {


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


        //Add event when attendee inserted


      //Use the 'marketing_event' instead of 'current' cause current references the updated/added/deleted record.


      //Current would work for updated or deleted cause the record exists


      //But once you delete it the error throws up


      // So refer the sys_id from the main record.



        var gr = new GlideRecord('x_snc_marketing_marketing_event');


        if(gr.get('sys_id', current.marketing_event)){


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


                              gs.eventQueue('x_snc_marketing1.attendee.added', gr,'','');


                      }


          //Add delete event


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


                    gs.eventQueue('x_snc_marketing1.attendee.deleted', gr,'','');


          }


  }


}