Manipulating Search

I have a grid application that I start in search mode.

I want to manipulate the search term using a regex before it enters the sql so I can remove any dashes.

My question is, how would I do this with script case?

For example, all phone numbers are stored in my database without the dash so if they search for 415-222-333, the query will return no results because it is stored in the database as 4152223333.

Re: Manipulating Search

I believe you can remove the chars in the onValidate event in search.
$new_phone = str_replace(’-’,’’,{phone_field});

The other option is to create a ‘new field’ in search and then you have complete control of how you want to search.

Regards,
Scott.

Re: Manipulating Search

Wait, so I have the ability to manipulate form values before they are sent to search?

That would be great!

Do you think this would work?

$new_phone = str_replace(’-’,’’,{phone_field});

{phone_field} = $new_phone;

Re: Manipulating Search

$new_phone = str_replace(’-’,’’,{phone_field});
{phone_field} = $new_phone;

You could use that, or use the field itself:


{phone_field} = str_replace('-','',{phone_field});

Re: Manipulating Search

Even better!

Thanks ScottMartin! :slight_smile: