56
Views
4
Comments
Solved
How to make different filters for an input field
Question
Service Studio Version
11.54.20 (Build 62656)


I'm making a query site, it has an input field where the user chooses whether to search by name or ID of a person through a RadioButton. I want to add a filter so that if the person searches for a name, it has to have at least 8 characters of text type. And I want to add another filter so that if the person searches for the ID, it must necessarily have 11 digits of type number. 

How to do this if the input field for both searches is the same?

2022-05-02 13-50-49
Paulo Ritto
Solution

I see you are using a text variable for the radio buttons from your images, the variable you're using is tipo_consulta.

First off, if one radio button is always selected by default, change the variable type to boolean as it makes maintainability easier and clearer code. But for examples purpose, I will do it with your code:

Also, keep in mind you don't need to do it exactly like this, this can be simplified. But yes, this is just to showcase somewhat similar to the action you currently have. So yes, add the condition to check the length of the field after your if of tipo_consulta="nome"

Let me know if you need further help,

Paulo


2023-08-29 14-56-14
vn_perpetuo

Hello Paulo, an unforeseen situation has arisen and I will have to make a trip now, unfortunately I will not be able to check it now, but tomorrow as soon as I arrive I will see the details you sent and I will give you the answer here. Thank you very much for your attention.

2022-05-02 13-50-49
Paulo Ritto

Hi Vinicius,

I assume you have boolean variable behind your radio buttons (or even if it is a variable from another type) it will hold a specific value when the radio button 1 is selected, and another different value when radio button 2 is selected. So on your logic you will have to use that variable of your radio button fields in your validation.

For example's sake, let's assume you have a boolean variable called SearchById (which is TRUE if the radio button to search by Id is selected, and FALSE if you are searching by name)

In your validation you would do something like this (PSEUDO CODE):

IF SearchById AND Length(SearchFieldVar) <> 11   -> throw error regarding that

IF not SearchById AND Length(SearchFieldVar) < 8 -> throw error regarding that


This is just pseudo-code but the whole point is that, of course, you need to use the currently selected value of your radio buttons variable in your logic to assess and make your necessary validations


Let me know if you need further help,

Paulo

2023-08-29 14-56-14
vn_perpetuo

Hi Paulo, thanks for the help.

I understood a little of what you went through, in my case I use the same variable for the 2 radiogroups. 

I put 2 pictures attached.

So, from what I understand, should I add a validation in the assign after the IF tipo_consulta that is in the image?

SC1.png
SC2.png
2022-05-02 13-50-49
Paulo Ritto
Solution

I see you are using a text variable for the radio buttons from your images, the variable you're using is tipo_consulta.

First off, if one radio button is always selected by default, change the variable type to boolean as it makes maintainability easier and clearer code. But for examples purpose, I will do it with your code:

Also, keep in mind you don't need to do it exactly like this, this can be simplified. But yes, this is just to showcase somewhat similar to the action you currently have. So yes, add the condition to check the length of the field after your if of tipo_consulta="nome"

Let me know if you need further help,

Paulo


2023-08-29 14-56-14
vn_perpetuo

Hello Paulo, an unforeseen situation has arisen and I will have to make a trip now, unfortunately I will not be able to check it now, but tomorrow as soon as I arrive I will see the details you sent and I will give you the answer here. Thank you very much for your attention.

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