Ax2009 Event Processing Error

  • February 22, 2012
  • 2 Comments

I have a customer that gets a error every time the EventJobCUD-batch (Change Based Events) runs. They got the following error:

After some reseach I found out that when 2 fields are changed at the same time, you go several times through the listChangedFieldsEnumerator (location ClassesEventProcessorCUDprocessUpdate)

1
2
3
4
5
6
7
8
9
while (listChangedFieldsEnumerator.moveNext())
{
    // In this simple case we use the new and the original changed field value as
    // recorded at event detection time:
    [thisFieldId, changedFieldValue, origChangedFieldValue] = listChangedFieldsEnumerator.current();
 
    if (rule.AlertFieldId == thisFieldId)
        break;
}

The code underneed simulates the same situation in a small job:

1
2
3
4
5
6
7
8
9
static void Job5(Args _args)
{
    anytype any;
    ;
    any = ABC::A;
 
    // next line will throw a error
    any = BatchStatus::Canceled;
}

And here we get the basic same error “Error executing code: Wrong argument types in variable assignment.”

I modified the code so the anytype is assigned only when the field is correct:

1
2
3
4
5
6
7
8
9
10
11
12
while (listChangedFieldsEnumerator.moveNext())
{
    // In this simple case we use the new and the original changed field value as
    // recorded at event detection time:
    thisFieldId = conpeek(listChangedFieldsEnumerator.current(), 1);
 
    if (rule.AlertFieldId == thisFieldId)
    {
        [thisFieldId, changedFieldValue, origChangedFieldValue] = listChangedFieldsEnumerator.current();
        break;
    }
}