Page 1 of 1

SvySearch add Searchprovider in valuelist

PostPosted: Fri Jul 30, 2021 10:42 am
by muhammadhammadmobin
Hi all,
Hopefully, you all are doing well.
Can anyone help me with how can I use the custom value list in the search provider?

Re: SvySearch add Searchprovider in valuelist

PostPosted: Fri Jul 30, 2021 11:48 am
by paronne
Hi,

you can use substitutions to search real values of a custom valuelist.

Code: Select all
var provider = simpleSearch.addSearchProvider(dataProviderID.toLowerCase());

var vlItems = application.getValueListItems(column.valuelist);
if (!vlItems.getMaxRowIndex()) {
   return;
}

// add valuelist substitutions
for (var index = 1; vlItems && index <= vlItems.getMaxRowIndex(); index++) {
   var vlItem = vlItems.getRowAsArray(index);
   provider.addSubstitution(vlItem[0], vlItem[1])
}


Please note substution won't be able to find values with partial matches (such as contains or starts with);
it can find only exatch matches.

e.g.
Valuelist values:
admin|1
basic|2
audit|3

user-type:admin // where "admin" is substituted to some stored value 1, will find all records having user type = 1.
user-type:adm // substitution doesn't have a match for "adm", it won'f find any user type.

Regards,
Paolo

Re: SvySearch add Searchprovider in valuelist

PostPosted: Fri Jul 30, 2021 12:10 pm
by muhammadhammadmobin
paronne wrote:Hi,

you can use substitutions to search real values of a custom valuelist.

Code: Select all
var provider = simpleSearch.addSearchProvider(dataProviderID.toLowerCase());

var vlItems = application.getValueListItems(column.valuelist);
if (!vlItems.getMaxRowIndex()) {
   return;
}

// add valuelist substitutions
for (var index = 1; vlItems && index <= vlItems.getMaxRowIndex(); index++) {
   var vlItem = vlItems.getRowAsArray(index);
   provider.addSubstitution(vlItem[0], vlItem[1])
}


Please note substution won't be able to find values with partial matches (such as contains or starts with);
it can find only exatch matches.

e.g.
Valuelist values:
admin|1
basic|2
audit|3

user-type:admin // where "admin" is substituted to some stored value 1, will find all records having user type = 1.
user-type:adm // substitution doesn't have a match for "adm", it won'f find any user type.

Regards,
Paolo


Thanks, Paolo for your response.
It worked for me.

Marking this thread as RESOLVED.