No valid document identified from the entity key

I recently encountered this problem while using the AIF framework in Dynamics AX 2009. I got it in the AIF Queue manager when one of my messages failed.
Since the message “No valid document identified from the entity key” doesn´t really give you a good clue of that the problem really is, I had to do some debugging. I found that the error occurred when the class AifConstraintListCollection did not contain any constraints and the message(document) was associated with a query.


if (queryAssociatedToDocument && 
    _constraintListCollection.getConstraintListCount()== 0)
    documentFound = false;

This is because the method Classes/AxdBaseRead/serializeQuery cannot find a record based on the query in question:

axdBaseRecordInfo = 
if (axdBaseRecordInfo == null)
//For find operations there may be no 
//records found by the query.
common = axdBaseRecordInfo.getRecord();
constraintList = new AifConstraintList();
axdBase.getConstraintList(common,constraintList) ;
_constraintListCollection.addConstraintList(constraintList) ;

(My operation is read)

As you can see, since no record is found based on my query I don´t get any further than the return command. And the constraints are set a couple of lines below.

So what was the problem? Well in my own data of course. There was a bug in my code that resulted in an empty query because a value in one of the table’s wasn´t filled in correctly.

When I did this investigation I also found that this message “No valid document identified from the entity key” is being thrown from many places, the above example just happens to be where it was thrown in my case, so maybe this isn´t the answer for you just because you get the same message. But maybe it is.

Last 5 posts in Development

2 thoughts on “No valid document identified from the entity key

  1. Hi, I had a similar problem. All AIF messages are being tested just before the serialization occurs. One of the tests checks wheter the source data still exists. To perfom this test AIF make a lookup based on the primary key index. If however one of the fields is a datetime you might experience this error as Ax sometimes stamps values in the milisecond part of the field. This (full) value however is not visible from the ax client, only from sql. I suspect a kernel error.

  2. At least in AX4, the error can also occur if record has been modified or deleted while the message is still in the AIF queue. That is, before the AIF batch job has processed the message from the queue.

Leave a Reply

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