1

I have a list with columns FirstName and LastName. Using API query, I am able to search for the first name or the last name. i.e.:

_api/web/lists/getbytitle('Employee')/items?$filter=substringof(%27jo%27,Title)and substringof(%27bl%27,LastName)&$select=Title

But i have a requirement where the search text is "Joe Bloggs" and it should search the firstname and lastname for this full name.

Is it possible to filter the list using the full name?

1 Answer 1

1
var searchtext = //get search text from query results or textbox
var FirstNameSearch = searchtext.split(" ")[0];
var LastNameSearch = searchtext.split(" ")[1];

"_api/web/lists/getbytitle('Employee')/items?$filter=Title eq '" + FirstNameSearch + "' or LastName eq '" + LastNameSearch+ "'&$select=Title";

You can probably build out the logic to search again if there are no results for "no results for , searching for users with firstname of or lastname of " or something similar.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.