Friday, December 4, 2009

Flush Events related tables quickly

Quick job to delete all records from Events related tables. Inspired by this posting of Nitesh Ranjan.

static void FlushEventInbox(Args _args)
{
/*
To implement Alert functionality, Dynamics AX uses following tables:
EventParameters
EventCompanyRule
EventCUD

EventInbox
|
|- EventInboxData
|- EventRule
|
|-EventRuleData
|-EventRuleField
|-EventRuleIgnore
|-EventRuleIgnoreAggregation
|-EventRuleRel
|
|-EventRuleRelData
*/
EventRuleRelData EventRuleRelData;
EventRuleRel EventRuleRel;
EventRuleIgnoreAggregation EventRuleIgnoreAggregation;
EventRuleIgnore EventRuleIgnore;
EventRuleField EventRuleField;
EventRuleData EventRuleData;
EventRule EventRule;
EventInboxData EventInboxData;
EventInbox EventInbox;
;
if (Box::okCancel("Flush all Events related table?", DialogButton::Cancel, "Confirm deletion",
"Delete all records from: delete_from EventRuleRelData, EventRuleRel,"
+" EventRuleIgnoreAggregation, EventRuleIgnore, EventRuleField, EventRuleData,"
+" EventRule, EventInboxData, EventInbox") == DialogButton::Ok)
{
delete_from EventRuleRelData;
delete_from EventRuleRel;
delete_from EventRuleIgnoreAggregation;
delete_from EventRuleIgnore;
delete_from EventRuleField;
delete_from EventRuleData;
delete_from EventRule;
delete_from EventInboxData;
EventInbox.skipDeleteMethod(true);
EventInbox.skipDeleteActions(true);
delete_from EventInbox;
}

}

3 comments:

SebDra said...

Hi,
i think the use of skipDataMethods is in this context not correct. The method skipDataMethods(true) will skip future calls of update and insert methods. To skip future calls of the delete-method you'll have to use the skipDeleteMethod(true)
bxe,
SebDra
http://www.crazy-club.de/blog

wojzeh said...

Thank you for the remark. I changed the code.

Anonymous said...
This comment has been removed by a blog administrator.