web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Deleting Notifications in AX2012

(0) ShareShare
ReportReport
Posted on by

Hi,

Can anybody tell me how to delete the old notifications in my user account. one or two years back I have created some batch jobs from my user name and I have enabled the option of notification when it gets ended and getting any errors. The batch jobs were for pulling the data from my shops and I put the frequency every 30 minutes and I got so many shops. So what has happened is since then all these notifications are piled up and now it is taking too much time for me to login to my account. The message queue is showing millions of records. How can I delete these old notifications? Is it possible to delete it from Table level?

I tried the option in system administration but nothing is happening. It is just getting frozen and nothing is deleting.

Your help is very much appreciated.

Thanks,

Dhanoop R.Warrier

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Sohaib Cheema Profile Picture
    49,438 User Group Leader on at

    you may use Notification Cleanup form that provides the option to use it as batch job.

    In addition have a look at a blog post, which is old for ax 2009, but still valid.

    setting up batch job for this can make life easy, else you have to run it manually and wait for it get finished.

  • Suggested answer
    Iulian Cordobin Profile Picture
    8,201 on at

    Yes, you should be able to use this code: (just create an empty class in your AOT, with an empty method and then copy / paste over the following code):

    public static void main(Args _args)
    {
        EventInbox      eventInbox;
        EventInboxData  eventInboxData;
        
        date        deleteUntil = systemDateGet() - 90;
        utcDateTime utcDeleteUntil = DateTimeUtil::newDateTime(deleteUntil, 0);

        eventInbox.skipDataMethods(true);
        eventInbox.skipDeleteActions(true);
        eventInbox.skipDeleteMethod(true);
        

        ttsbegin;


        delete_from eventInboxData
        exists join eventInbox
            where eventInboxData.InboxId == eventInbox.InboxId &&
                  eventInbox.UserId == curUserId() &&
                  eventInbox.AlertCreatedDateTime <= utcDeleteUntil;

        delete_from eventInbox
            where eventInbox.UserId == curUserId() &&
                  eventInbox.AlertCreatedDateTime <= utcDeleteUntil;

        ttscommit;

       
        info('Done');
    }

    This will delete the alerts up to a specific date (here you have current date - 90 days) for your user (the user running this code).

    To run this just hit Run (or open) in the class. It's the same as a job, but we are doing this in a class, preparing for the next AX version.


    On a live system, use this at your own risk (usual disclaimer).

  • Community Member Profile Picture
    on at

    Hi Sohaib,

    I have already tried the option of notification cleanup but it is taking too much time and application is getting frozen and nothing is deleting after so many time.

    If there any option in database level, it is more convenient for me.

    Thanks,

  • Community Member Profile Picture
    on at

    Hi Lulian,

    Thanks for the suggestion. But let me ask you if there is any option to delete the same from database. I am not familiar with AOT classes.

    Thanks,

    Dhanoop R.Warrier

  • Iulian Cordobin Profile Picture
    8,201 on at

    I was about to mention that Sohaib's option of using the standard periodic task is also a perfect way to go, without the hassle of writing code.

    However, you can use the writing code approach if that gets the job done faster.

  • Suggested answer
    Sohaib Cheema Profile Picture
    49,438 User Group Leader on at

    if you want to delete by x++ code or sql server you can do it as below

    basically we need to delete data from two tables.

    a) EventInbox

    b) EventInboxData

    Make sure to delete EventInboxData, prior to deleting from EventInbox

    following can be sequence of deletion

    1) set status of EventInbox.SendEmail  = 0/false

    2) delete related records of EventInboxData (based on relationship of two tables)

    3) delete records of EventInbox

  • Verified answer
    Iulian Cordobin Profile Picture
    8,201 on at

    Alright. Yes, you can do that from SSMS, just get a query like:

    USE MicrosoftDynamicsAx

    truncate table EventInboxData -- fastest option, drops all data in the alerts table

    truncate table EventInbox -- fastest option, drops all data in the alerts table

    -- delete from EventInboxData -- where add where conditions if you need to

    -- delete from EventInbox -- where add where conditions if you need to

    But be careful in using this when connected directly to your sql dbs.

    Note: I have forgot that there is a EventInboxData table in my initial post, so depending on whether you want to still retain some alerts, you may needs to apply some logic to your T-SQL where clauses.

    The question is: do you want to keep some data, or wipe them all?

  • Community Member Profile Picture
    on at

    Hi Lulian,

    I want to wipe the notification which I have created from my id only. Others can be remained.

  • Community Member Profile Picture
    on at

    Hi Sohaib & Lulian,

    I have deleted only from the table "eventinbox" where I put the criteria my user name. Once it is finished I found that notifications have been deleted from my user name and other users notifications are there. Is that alright? May I need to delete from "eventinboxdata" as well?

    Thanks,

    Dhanoop Warrier

  • Verified answer
    Sohaib Cheema Profile Picture
    49,438 User Group Leader on at

    This table (EventInbox) does not have CreatedBy enabled, in standard AX. So, unless you have not enabled this field (CreatedBy), we cannot filter it with the way as you require(records created by you)

    Edit:

    if you will enable now(CreatedBy) there will not be any change on historical data or previously created records.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans