5.3 Use Combo Boxes to Select From a List

5.3 Use Combo Boxes to Select From a List

  
In the combo box, you added a 'special list' with an [ALL] option. Right after that you said that this option would get value 'null' and be ignored in the query because it is a search parameter.

This is not the way you configured tthe combo box.The All option will have a value of '0' zero which is not null. Luckily there are no categories with id 0, s0 the query will still work as intended.

My question: Can I include an option in a special list without a value (a real null)?
Hi M. Van Kempen,

Thank you for your feedback.
Special lists are... well special! In fact the value that you set in the special list is not bound to the variable of the combo box, it is bound to the special list variable if it is defined. This is tricky I know... you can read all about it in the reference help.
Hence this is why the combo box variable will have a null value (by the way for any entity identifier the null value is actually zero) and the query still works.

Can you add other options to the special list? Yeah, sure.On that case you'll need to add a special variable so that you can validate the user's choice. You can even create a combo box only with special list values...

About your question: why do you need an option without a value?
hi
i i=have one query related with fetching data in combo-box.
In my project i have two comobox in which 2nd is dependent on first. when i select data from 1st combo bax send need to show respective data only. 
Suppose in 1st when i am selecting teacher 2nd need to show me only teachers
and when i select professor in 1st 2nd only professor.
can you suggest me in which video i will get this 
thank you
Hi gajanan bejgamwar,

There's no video with that pattern. Despite this once you cover module 10 which covers how to use the ajax capabilities on the OutSystems Platform you'll be able to implement this pattern.

One more thing you'll need to know is that the combo box has an event associated with it. Check the Reference Help for details on this widget.

Cheers
Are there any examples or pointers to how someone would get a variable from a user and then use that variable as part of an advanced Query and/or what is the best practice way to pass a variable from one screen to another (i.e. "in memory") ... I have done this in other languages etc just want to see how it is done by OutSystems... Thank you!!!
Hi Claudio,

About sending variables across screens "in memory", I don't think there are any videos that have an example about that.

To pass variables between screens, you need to use input parameters. If you review the Show a Record from the Database video, you'll see an example of sending variables to other screens. Yes, the example on that video is not done "in memory".
But, if at the end of a Screen Action, you decide to navigate to other screen, and that screen has input parameters, then you are sending variables to other screen "in memory", since this will be a server-side transfer.

About using variables in Simple or Advanced Queries. As explained in the Overview of Simple Queries video, queries have their own scope. If you want to use variables inside a query, you need to send them by parameter.
Thank you ... and what is the correct syntax to refer to an input variable when you bind it to something ? Lets say my variable is named "var1" ... what is the syntax? session.var1 or ???
Thanks!
This video shows a combobox that picks up a single "source attribute" from the foreign key which is the category.

How would I show the user two attributes. In my Use Case, I have a table with information about a "person" so I'd like to show both the first and last names in the combo box.
Hi Mark,

You can use an advanced query to create an output combining both attributes and bind the output of this query to the combobox.

Cheers
In this lesson, my question pertains to the combo box that holds the list of Category Names and is used for search purposes. The Source entity is Category and the Source attribute is Name so we see a list of names in the combox box drop down menu. However, the local variable we are using is CategoryId of type Identifier which is what will be used in the query in the preparation whenever the search is executed. Is this part of the special functionality that the combo box offers and that is even though we have picked the source attribute of "Name" Outsystems will grab the Id from the Category table and assign it to the local variable that is of type Identifier we have created?
Hi Sam,

Yes that's it. This is the usual behavior of a combobox in HTML you see a value on the screen but what actually gets send to the server and eventually to the database is a different value (typically an identifier of some sort)

Cheers

hi.

I set a text for value 0 in the special list, how to reset de value selected in the combo?

if i assign the local variable attach to the combo to nullidentifier, its refreshes ok the grid but maintains the selected value on the combo and i whant it to be "all" ( value 0)

thanks.
Ana you need also to refresh the widget, either directly or a container that includes it. Are you doing it?

Hi,

in the action for the button, i do a assign to the local variable to nullidentifier, then i do a refresh to the grid, then i do a refresh to the widget table, and then ends.

comparing to .net how do i set de combolist.selectedvalue = 0 in the action of a button ?

The combo box does not store any values in itself. That's why you need to bind it with a variable, by setting the 'Variable' property of the combo box.

To change the combo box selected value, simply assign to the variable it is bound to.
For example, if you want that a combo box presents a value selected by default, in the Preparation action, assign a value to the variable that stores the combo box value.
ana almeida wrote:

Hi,

in the action for the button, i do a assign to the local variable to nullidentifier, then i do a refresh to the grid, then i do a refresh to the widget table, and then ends.

comparing to .net how do i set de combolist.selectedvalue = 0 in the action of a button ?
 
 
 Are you refreshing the combo box? It looks that that's just what is missing here. You need to refresh either the widget (combo box) or an element that contains it (e.g. a container).
Hi for some reason when  trying to introduce reverse order in my query GetCategories i noticed that all category.displayorder are valued 0 but it doesnt happen when i try to use the normal diplay order option in category, when i went to check the publish i found this warning:
Database Integrity Suggestion
 
Inconsistent database table and entity definitions: column 'OSUSR_2xi_Category.DISPLAYATTRIBUTE' exists in database, but there is no corresponding attribute in entity 'Category'.
Hi norman,

Here's what happened.
At first you created the DisplayOrder attribute as DisplayAttribute and you bootstraped the excel data into that entity. When you did this the DisplayAttribute didn't match the excel file so that column didn't get filled in in that process. Later you removed the DisplayAttribute and created the DisplayOrder but since the bootstrap action doesn't override data in the database that new column continues to be empty. (Inspect the BootstrapCategories action to understand the bootstrap process. Further ahead you have this video that details the bootstrap process and how to customize it)

How to get it working?
  1. Delete the Category entity and recreate it, or,
  2. Create a screen to edit the Categories and set the DisplayOrder.
I hope this helps you...

Cheers
André Vieira wrote:
Hi norman,

Here's what happened.
At first you created the DisplayOrder attribute as DisplayAttribute and you bootstraped the excel data into that entity. When you did this the DisplayAttribute didn't match the excel file so that column didn't get filled in in that process. Later you removed the DisplayAttribute and created the DisplayOrder but since the bootstrap action doesn't override data in the database that new column continues to be empty. (Inspect the BootstrapCategories action to understand the bootstrap process. Further ahead you have this video that details the bootstrap process and how to customize it)

How to get it working?
  1. Delete the Category entity and recreate it, or,
  2. Create a screen to edit the Categories and set the DisplayOrder.
I hope this helps you...

Cheers
 hum true deleted the category and remade it, and its ok... thank you very much
 
André Vieira wrote:
Hi norman,

Here's what happened.
At first you created the DisplayOrder attribute as DisplayAttribute and you bootstraped the excel data into that entity. When you did this the DisplayAttribute didn't match the excel file so that column didn't get filled in in that process. Later you removed the DisplayAttribute and created the DisplayOrder but since the bootstrap action doesn't override data in the database that new column continues to be empty. (Inspect the BootstrapCategories action to understand the bootstrap process. Further ahead you have this video that details the bootstrap process and how to customize it)

How to get it working?
  1. Delete the Category entity and recreate it, or,
  2. Create a screen to edit the Categories and set the DisplayOrder.
I hope this helps you...

Cheers
 hum true deleted the category and remade it, and its ok... thank you very much
 
I didn´t have any data in the category combo until i've supplied "Source Record List".
In the video only by setting Souce Entity teh combo had data.
I'm i missing something?
I'm replayed that section of the video and didn't understand what i was doing wrong. 
Hi Nuno,

I don't need to provide the source record list. The issue might be related with the bootstrap, since this is an assynchronous operation it might happen that when you opened the page the categories were not yet bootstraped. Try to remove the source record list and set only the entity in the combo box to see if it works. If it doesn't share the module with us so that we can figure out what the problem is.
André Vieira wrote:
Hi Nuno,

I don't need to provide the source record list. The issue might be related with the bootstrap, since this is an assynchronous operation it might happen that when you opened the page the categories were not yet bootstraped. Try to remove the source record list and set only the entity in the combo box to see if it works. If it doesn't share the module with us so that we can figure out what the problem is.
 Thanks André,
Now it worked, i closed all browser tabs and used a new after the deploy and it worked as expected.
 
Hello, I have a legacy table, where I have several text fields that would optimize the filling of the issue forcing the user to choose between pre-defined options, avoiding different records just by misspelling, but as a table existing, I can not make the relationship necessary to use the combo box would have a way to use the combo with static data, no relationship, just carrying a list of options?

Tks
IGOR
Hi Igor,

Sure you can. My suggestion is that you go back to the reference documentation (just press F1 on a combo box) and check the special list and special list variable. By the way it would be great to receive feedback on it. We can't cover every single use case in the online training and we sincerily hope that people find the information in the reference help useful.

Thanks and Cheers
Hello André, could you help me with the example below, I have read the reference you made, is not even clearer am trying the way the file is sent, but I know that is wrong, and I am unable to move.

Thank you
Hi Igor,

In your example you have a static entity to populate the combo box. With this configuration the vallue that will be stored in the variable is the entity identifier (in your case estadocivil identifier). Therefore you need to change the definition of the client entity. Instead of having a estadocivil Text attribute you should have a estadocivilId which should be a estado civil identifier, this means a foreign key to the static entity estadocivil.

Cheers
Olá , André vou falar em português pois acho que não estou sendo claro , já que meu inglês não é muito bom e tenho que recorer a tradutores.
Bom deixando bem claro o que eu quero fazer , tenho um tabela com um campo texto ( estado civil ) por exemplo, que já contém um conteudo  eu  quero no formulário, de inserção , e edição , não deixar o campo imput text simples , pois como são algumas variações de conteudo , se eu deixar como campo texto para preencher , vou ter muitos erros , de preenchimento , para contornar isso , gostaria de ter um combo box, com valores em texto para serem armazenados como texto mesmo , em HTML puro por exemplo , eu faria assim :

<select name="cars">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="fiat">Fiat</option>
<option value="audi">Audi</option>
</select>

Eu consultei o Help como você disse , mas não achei algo que me indicase como fazer um combo box de forma simples assim .

Como eu falei antes minhas tabela já existe , eu não tenho como fazer relacionamentos , é apenas para evitar erros de digitação nos inputs.

Obrigado pela atenção .
Oi Igor,

Sem problema, eu é que não percebi!
Nesse caso deve usar mesmo a special list. Em vez de mapear o campo Variable ao record to EditRecord mapeei na propriedade Special Variable. Depois introduza os possíveis estados civis na parte Special List (Value 1, Option 1) penso que esta é a forma mais simples. Neste caso não precisa da Static Entity.

Espero ter ajudado agora :$
Obrigado André , agora sim entendí o que tinha que ser feito , funcionou perfeitamente.

Abraços
In a ComboBox there is any way to select more than one "element" ?


TIA
Alberto
The widget for that is the List Box and not the Combo Box.
Hello

the source record of my combobox is SQL1.list and Source Attribute is a result of this sql query,so what about the Source identifier?help please see this attach please
cheers

What is the output of SQL1?
André Vieira wrote:
What is the output of SQL1?
 the output of this SQL1 is Structure,have you see this attach please
cheers
 
Your structure does not have an identifier. If you want to select an Engin to fill in the value of an attribute of the ReclamationForm that is a Engin Identifier then the output of your SQL should be either the Engin entity which is probably simpler or, if you want to stick with the strucuture, then the attribute EnginId in the structure shuold be of data type Engin Identifier.
André Vieira wrote:
Your structure does not have an identifier. If you want to select an Engin to fill in the value of an attribute of the ReclamationForm that is a Engin Identifier then the output of your SQL should be either the Engin entity which is probably simpler or, if you want to stick with the strucuture, then the attribute EnginId in the structure shuold be of data type Engin Identifier.
 hello Vieira
it's ok thank you
But i have one condition: Unite.UserID = Session.UserId  where can i put it in my query because i have a different sessions in my application
 
If you are using the SQL node you need to create an input parameter of data type User Identifier to pass the Session.UserId value.
André Vieira wrote:
If you are using the SQL node you need to create an input parameter of data type User Identifier to pass the Session.UserId value.
 Hello Vieira:
I created an input parameter as you sad but i have an error, so this is my advanced query so what i want exactly is to make this condition {Unite}.[UserID]=Session.UserId :

SELECT {Affectation}.[EnginID],{Engins}.[Num_Ordre],{Engins}.[Marque]
from {Affectation},{Engins},{User},{Unite}
where {Affectation}.[EnginID]={Engins}.[Id] and
 Session.UserId=@user and
 {Unite}.[UserID]=@user
 cheers
Remove the Session.UserId=@User form the query. Use the Session.UserId as a value for the @User Parameter. The data type of @User should be User Identifier
André Vieira wrote:
Remove the Session.UserId=@User form the query. Use the Session.UserId as a value for the @User Parameter. The data type of @User should be User Identifier
 Ok it's done thank you so much
best cheers