Home / News / The new Lookup validation in Dynamics 365 version 9
20 June 2018
By: Karin van Gent

The new Lookup validation in Dynamics 365 version 9

Featured image for blog about the new lookup validation in D365 version 9

Is it a bug that will be solved soon? No, this is how it works from now on!

During one of our latest projects we were unpleasantly surprised by numerous Javascript error messages. These error messages can be a common sight in the development phase of a project, which is why both the customer and our team always thoroughly test the solution. This time though, the amount of error messages was proportionately so high, that we found it necessary to do a thorough investigation of the entire Dynamics 365 system, the result of which we shared with Microsoft. The conclusion? Microsoft has made an unplanned change and they are not going to revert it.

To the experienced consultants, there is no need to explain that Lookup fields in Dynamics 365, refer to a related entity. For years now we are used to remove values in a Lookup field manually. In addition to that, Microsoft introduced the ‘Remove Value’ button in an earlier version of Dynamics 365, which is accessible from the “Lookup More Records” pop-up.

During first introduction of the ‘Remove Value’ button, the result where the same as manually removing the value, which could simply be validated in Javascript by reviewing if the value was empty (e.g. NULL).

In version 9 however, Microsoft introduced several user interface modifications which also resulted in a behaviour change of the “Remove Value” button that resulted in the above mentioned error messages. By using the ‘Remove Value’ button in version 9 the field is no longer emptied (e.g. NULL) but it becomes an empty array.

Our support ticket made some bells ring at Microsoft and they concluded that this is an unforeseen behaviour change. Microsoft decided not to change this unplanned new behaviour since version 9, but instead will update the Microsoft documentation online. From now on, officially, we have to check every Lookup for both NULL and an empty array as per example below.

This is how it used to work: formContext.getAttribute(‘dp_location’).getValue() != null
This is how it works from now on: formContext.getAttribute(‘dp_location’).getValue() != null &&
formContext.getAttribute(‘dp_location’).getValue().length > 0

Of course you can wait until Microsoft publishes the new documentation set, but they stated that the update of the documentation will at least take 3 to 6 months. So if you cannot wait that long and have any questions on this matter, send me an e-mail to info@dynamicpeople.nl and we will support you. With the best interest for our customers in mind, we as competitors should act like colleagues and support each other.