60
Views
13
Comments
Solved
Multiple input search in search bar
Question

Hi all,

I'm trying to achieve multiple inputs search, each time i input the parameter, its show index 1 is out of range. How to solve the error and allows multiple input?

Search criteria:

1 input: Australia

2 inputs: Australia Test

OnSearch button

GetOffice Filters

Error:

Example: Australia

No record found.


Example: Australia <space>


TestSearch.oml
2021-08-12 05-19-40
Shubham Janbandhu
Solution

For type Australia, it will returns two records and for Name + Address, bit changed the filter condition please update it.

SearchKeyword = "" or If(vTextList[1].Value = "", Office.Name like "%" + vTextList[0].Value + "%",If(vTextList[0].Value <> "" and vTextList[1].Value <> "", (Office.Name like "%" + vTextList[0].Value + "%") and (Office.Address like "%" +vTextList[1].Value+ "%"), (Office.Name like "%" + vTextList[0].Value + "%") or (Office.Address like "%" + vTextList[1].Value + "%")))

you can copy paste.

Let me know other conditions as well so I can modify it if needed.

 

Regards,

Shubham



2024-12-10 04-40-04
Gitansh Anand

Hi @Drexxor Ho, I am adding an updated OML, please look at it.

The problem was when you type only one word the list will only have one value hence there is no index 1 and you get the error.

What I did was removed the sting split and the list, I used built in replace function to replace spaces with comma, then changed the filter condition according to that.

Thanks
Gitansh Anand

TestSearch.oml
UserImage.jpg
Drexxor Ho

Hi Gitanash, 

When i type A in the search bar, Australia did not come out. I needed to type the exact word search condition. How can i sort it out?


(SearchText = NullTextIdentifier() or Index("," + SearchText + ",", "," + Office.Name + ",") <> -1) or (SearchText = NullTextIdentifier() or Index("," + SearchText + ",", "," + Office.Name + ",") <> -1 and Index("," + SearchText + ",", "," + Office.Address + ",") <> -1)


I try to add this but didnt work.

First input: Australia listing came out
Second input: Australia Test (Didn't search)

2024-12-10 04-40-04
Gitansh Anand
UserImage.jpg
Drexxor Ho

i tried, It didn't return the results i expected

2024-12-10 04-40-04
Gitansh Anand

Hi @Drexxor Ho, try with this filter once, I am also add the updated OML

SearchKeyword = NullTextIdentifier() or ToLower(Office.Name) like "%" + ToLower(SearchKeyword) + "%" or ToLower(Office.Address) like "%" + ToLower(SearchKeyword) + "%" or Index("," + ToLower(Replace(SearchKeyword, " ", ",")) + ",", "," + ToLower(Replace(Office.Name, " ", ",")) + ",") <> -1 or Index("," + ToLower(Replace(SearchKeyword, " ", ",")) + ",", "," + ToLower(Replace(Office.Address, " ", ",")) + ",") <> -1

Thanks
Gitansh Anand

TestSearch.oml
2021-08-12 05-19-40
Shubham Janbandhu

Hi Gitansh Anand and Drexxor Ho,

I was trying to understand this below condition given by Drexxor,

As per my understanding vTextList[0].Value is for Office.Name and vTextList[1].Value is for Office.Address means user can search only two string. If that is the scenario, then I made changes to the filter condition as mentioned below.

By using this filter, the Index out of range error has been fixed. Only the thing is needed to append vTextList.Values with ""(empty string) on OnInitialize. Now filter is also working as expected. Also check OnSearch action.

Result:

Search Office.Name as "aus" and Office.Address as "tk"

I don't know if this is the exact requirement but tried to solve it.

@Drexxor Ho, let me know if it is correct.

Updated oml.

Regards,

Shubham




TestSearch.oml
UserImage.jpg
Drexxor Ho

Hi Shubham,


When i type Australia, it will returns two records.


When i want to search the exact Name + Address, the output should be the following:

2021-08-12 05-19-40
Shubham Janbandhu

yeah, sorry my mistake I corrected it, and it is working now.

Updated condition.

Link: Demo. Now, Name and Address working as expected.

 

Thanks,

Shubham

TestSearch.oml
2024-12-10 04-40-04
Gitansh Anand

Hi @Drexxor Ho, Did you try the updated filter condition I provided? I am adding the condition again, and you can check the OML from my last reply.

SearchKeyword = NullTextIdentifier() or ToLower(Office.Name) like "%" + ToLower(SearchKeyword) + "%" or ToLower(Office.Address) like "%" + ToLower(SearchKeyword) + "%" or Index("," + ToLower(Replace(SearchKeyword, " ", ",")) + ",", "," + ToLower(Replace(Office.Name, " ", ",")) + ",") <> -1 or Index("," + ToLower(Replace(SearchKeyword, " ", ",")) + ",", "," + ToLower(Replace(Office.Address, " ", ",")) + ",") <> -1 

Thanks
Gitansh Anand

2021-08-12 05-19-40
Shubham Janbandhu
Solution

For type Australia, it will returns two records and for Name + Address, bit changed the filter condition please update it.

SearchKeyword = "" or If(vTextList[1].Value = "", Office.Name like "%" + vTextList[0].Value + "%",If(vTextList[0].Value <> "" and vTextList[1].Value <> "", (Office.Name like "%" + vTextList[0].Value + "%") and (Office.Address like "%" +vTextList[1].Value+ "%"), (Office.Name like "%" + vTextList[0].Value + "%") or (Office.Address like "%" + vTextList[1].Value + "%")))

you can copy paste.

Let me know other conditions as well so I can modify it if needed.

 

Regards,

Shubham



UserImage.jpg
Drexxor Ho

THanks this works but it seems a little complicated. Is there a better way to deal with this kind of search inputs?

2021-08-12 05-19-40
Shubham Janbandhu

glad I help you out for now. It was also complicated and new scenario for me as well. Let me check if I can minimize it.

Thanks!

2021-08-12 05-19-40
Shubham Janbandhu

Hi Drexxor Ho,

Updated oml.

Try this condition.

 

Result:

Hope this helps.

Regards,

Shubham


TestSearch.oml
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.