show a message in a lookup field

Good day all. Is there a way to show a message in a lookup field if the typed value does not exist (No results found etc). Rather than just having the lookup show nothing. Thanks.

You may use “Lookup_Selecting” server event to do that. For example, from “orders” table in the demo project, you want to check the EmployeeID dropdown field (which will be derived from “employees” table) whether contains data or empty:if ($fld->Name == “EmployeeID” && (CurrentPageID() == “add” || CurrentPageID() == “edit”)) {
$this->clearMessage();
$sSQL = $fld->Lookup->UserSelect;
$sSQL .= " WHERE " . $fld->Lookup->UserFilter;
$rs = Execute($sSQL);
if ($rs && !$rs->EOF && AllowListMenu(‘{DFB61542-7FFC-43AB-88E7-31D7F8D95066}employees’) ) { // you need to check also whether the user has List permission
//$this->setMessage($sSQL);
} else {
$this->setMessage(“Data selection not found”);
}
}

Thanks for the tip. Unfortunately that isn’t what I was looking for (I do wish I could edit my posts lol). Let me explain again.

The feature is already there kinda I just want to go the extra step if possible. Btw I was referring to a auto-suggest text field not a dropdown menu. The default PHPmaker behavior is that when the user types and no result is found the error message “value does not exist” only appears after the user changes focus from the field. I would like the “value does not exist” message to appear while the user is still in the field and no results are found. I assume this has to be done with jquery. I hope that explains it better.Thanks in advance.

At least, have you tried the code I mentioned above?

I did. It actually threw up some sql errors (i think cuz of the where clause) so I commented that out. This works like you said if the source table is empty but this is only feasible for a drop down menu not a lookup text field. Like I said the error message is basically already there in phpmaker. It currently shows when the user clicks out and loses focus of the field but it would be more efficient if the error message was shown in the same spot as the results, as the users types and no matching result is found. A simple client side event on the text field perhaps?Thanks in advance.

Use the code given by mobhar to detect when you need to show your message.When you want to indicate that no values exist, place your message using static array as data:

$fld->Lookup->setOptions([
[“link value 1”, “display value 1”, “display value 2”, “…”, “”],
[“link value 2”, “display value 1”, “display value 2”, “…”, “”]
]);

where you can insert your message in “display value 1”.