Can not select records from a view with empty string values in one of the fields [AX 2012]

I have a view which has a field OfficeLocation (Originated from HcmWorkerTitle table). When I add a range to the AOT query properties (OfficeLocation field, Value property set to “”) view shows the records which have empty OfficeLocation and this is fine. But when I use While Select statement on this View and add a condition Where OfficeLocatoin == “” it doesn’t show any records.

Also, I have this view added to another Query and this Query added to a ListPage form as a DataSource. In the interaction class of this Form I overrode InitializeQuery(). In this method whenever I add a range officeLocationRange.value(SysQuery::valueEmptyString()) it doesn’t show any records for some reason. I checked and the SQL statement is correct:

SELECT * FROM UserRoles(UserRoles) WHERE ((OfficeLocation = ‘’))

I checked for other field and AX does absolutely the same. What am I missing? Is there another way to select records with empty strings in a view?

I don’t see any issue. Can you show us your select statement?

I’m just using standard While Select:

ENXUserRoles userRoles;

while select userRoles
where userRoles.OfficeLocation == “”
{
info(strFmt("%1", userRoles.User));
}

The strange thing is that even when I try to filter the data using Ctrl+G after opening browsing the View and type “” in OfficeLocation I get the result “The grid is empty”. It shouldn’t work like this. Apparently something is wrong with my query or view but can’t think of anything.

I cannot probably say what is wrong, without knowing what you have done?