Debug Alerts in Dynamics Ax 2009

Today I was creating some alert rules and needed to make some modifications to the alerting functionality. Something didn’t go quite as expected, so I wanted to debug the execution of an alert action.

Here is how you can do it :

  1. Make sure the debug mode is set to ‘when breakpoint’ for the user linked to the alert
  2. Put a breakpoint in the EventJobCud class, method Run
  3. Change the EventJobCus class, method Run so that it does not use the runAs command :

( Revert these changes when the debugging is done, but for now you need to make this change otherwise you will not be able to step into the EventAction classes for debugging)

void run()
{
    EventCUD             event;
    container             params;
    RunAsPermission    runAsPermission;
    ;
 
    this.expandCudRecords();
 
    while select event
          group by UserId
          where (event.Status == BatchStatus::Waiting) &&
                (event.CompanyId == curext())
    {
              params = connull();
              runAsPermission = new RunAsPermission(event.UserId);
              runAsPermission.assert();
 
              //BP Deviation Documented
              //runas(event.UserId, classnum(EventJobCUD), staticmethodstr(EventJobCUD, runCudEventsForUser),params,
              //      curext(), EventJobCUD::getLanguageId(event.UserId));
 
              EventJobCUD::runCudEventsForUser(params);
 
              CodeAccessPermission::revertAssert();
    }
 
    this.cleanupExecuting();
}
Warning: count(): Parameter must be an array or an object that implements Countable in /customers/5/2/1/ksaelen.be/httpd.www/wordpresses/dynamicsaxblog/wp-includes/class-wp-comment-query.php on line 399

Leave a Comment Yourself

Your email address will not be published. Required fields are marked *