Search by Employee ID or Employee Name in the same Search/Input Field

Hi,


I would like to ask how to search a record by either Employee ID or Employee Name on the same Search/Input Field?

I used the filter in the preparation:

SyntaxEditor Code Snippet

EmployeeName like "%" + SearchName + "%" or SearchName = "" or EmployeeId = IntegerToIdentifier(TextToInteger(SearchName))


the searching for employee id works fine, but when i search for the name it gives me "Error executing query"

Thanks in advance

Solution

Hello Miguel,


I think the problem lies here: 

IntegerToIdentifier(TextToInteger(SearchName))

When you convert a number to string there is no issue, but the same cannot be said for converting a string/text to integer.


For your scenario I think the best solution would be to have 2 queries split by a condition checking if the SearchName is an integer:

TextToIntegerValidate(SearchName)

Then for True branch query

EmployeeId = IntegerToIdentifier(TextToInteger(SearchName))

And for the False branch query

EmployeeName like "'%" + SearchName + "%'" or SearchName = ""


Hope this helps!

- Emman

Solution

Thanks Emman, It works :)