Hello,
We have identified another issue in a ANM2025 project and this is quite odd: CurrentPageID()
is empty (tested with Debug), when an API lookup call is executed.
So, we have a LookupTable that need to show different values for add
and edit
pages. We apply the SQL logig in Lookup_Selecting
event.
When in Debug mode, the query it is displayed correctly (with an added 0=1
), even in log i have the return of this function ( Log("CurrentPageID():" + ConvertToString(CurrentPageID()));
), but, when I click on the field in order to select a value, an API lookup call is being made, and the values are simply not filtered.
I can see clearly the sql in DevTools that is not executed for the required if\else branch (add
).
In Log file the above function return nothing.
This worked perfectly in ANM2021 (and other versions, in 2024 works OK, I can confirm).
Regards
Show your Lookup_Selecting codes
Here is a simple condition for a single lookup field:
public void Lookup_Selecting(DbField fld, ref string filter) {
if (fld.Name == "tk_in_category_id") {
fld.UseLookupCache = false; // Make sure that lookup cache is disabled
//Log("CurrentPageID():" + ConvertToString(CurrentPageID()));
if (ConvertToString(CurrentPageID()) == "add") {
fld.Lookup.UserFilter = String.Format("([LanguageCode] = '{0}') AND (COALESCE([isHidden], 0) != 1 AND COALESCE([isDisabled], 0) != 1)", ConvertToString(CurrentLanguage));
}
else {
fld.Lookup.UserFilter = String.Format("([LanguageCode] = '{0}')", ConvertToString(CurrentLanguage));
}
}
}
Enable debug mode and press F12 → Network to check the network response for the lookup, which should also include the SQL for the lookup.
You can also run the application in Microsoft Visual Studio 2022, add a break point in your Lookup_Selecting codes and see if the UserFilter is set up correctly.