When a user tried to set an alternative address on a purchase order, we got following error
The value xyz is not found in the map
After some debugging, the root of the problem was located in the form AddressSelect, in the setFocusRecord method. The value that could not be found was actually a tableid.
What happened: We have some modifications on site, where we setup the delivery address of purchase orders, based on the user who creates the order.
Now this form AddressSelect is used all over Ax, and tries to customize it's behaviour based on the origin of the current address setup. This is where things went wrong.
Let's look at the code:
At first, it's checked if a specific value exists as a key in a map. That's a good thing.
But later on in the same method, a lookup in the map is performed without a check. This will cause an error if the key does not exist. What happened in our situation.
By rearranging the code in this form, we quickly got rid of the error.
Lesson learned: Looking up a non-existent key in a map will cause an error in Ax. So if you are not sure that the value exists, first do a check and act accordingly.
(Version MS Dynamics Ax 2009 SP1 - HFR3)
How did you rearrange the code to fix it? The setFocusRecord() is the same as your screen shot above. I'm getting this error after creating my own AddressSelectForm_xxx class and modifying the base classes newAddressSelectForm method....
ReplyDeleteHi there,
ReplyDeleteThe problem is with the second red arrow on the screendump above. A lookup in a map is done for a non existing value.
So the solution can be to add a check first to see if the value is found.
Before the line 'this.parmActiveTopDS(form...', add a line with:
if(formdataSources.exists(focusTableId))