how to display year in combo box from 1905 to current year

how to display year in combo box from 1905 to current year

  

Hi friends,

                  How to display year in a combo box from 1905 to current year using site variables

Hi Karthik,

You can create a separate entity in your project and use the excel bootstrap method to upload the years from 1905 to 2095 and on preparation you can filter your list up to the current year only. So that it will work for future as well.

Regards,

Manish Jawla

Manish Jawla wrote:

Hi Karthik,

You can create a separate entity in your project and use the excel bootstrap method to upload the years from 1905 to 2095 and on preparation you can filter your list up to the current year only. So that it will work for future as well.

Regards,

Manish Jawla

hi Manish,

                    Any other option is avaliable like by incrementing the year using site variables



Hi Karthik,

Site variables should not be changed dynamically in your project it's not a best practice.

On preparation, you can iterate through a loop and create a list type variable of integer type, start the iteration by assigning the first value as  1905 then increment it until you reach the current year value.

Regards,

Manish Jawla

Hi Manish,

                  How to implement this logic


Karthik, its very simple. 

1. create a local variable of type list and data type integer.

2. In preparation drag a loop widget and assign that list type variable to the source, and you can set the start & total num of iteration depends upon the calculation of current year from 1905.

3. use the assignment operator to append the list.

4. bind the list variable to the combo box.

Karthik, i would recommend you to go through the tutorial of web application development of outsystem under the Learn Module. that will help u a lot, because these are basic solutions.

Regards,

Manish Jawla


Hi Manish,

The "loop widget" doesn't work like that. A For Each (the official name) loops over the content of a list. You can set the start and maximum number of enumerations, but if the list is shorter than that (and in your example it is empty!) there will be no iteration.

What Karthik needs to do is manually create a loop with an If, a variable that starts with 1905 and is incremented each loop, and a ListAppend, like this:

Hi kilian,

                        what we have to mention in list append's list and element

Hi Karthik,

The List is the local variable of type List of Integer, the Element is the local variable Year (or whatever you name it). That said, you really should've been able to figure that out yourself, make sure you're comfortable with a language (or platform) before trying to create actual applications!

Hi kilian,

                        How to bind list values to combo box

Hi Karthik,

It seems that a list of a basic type (like Integer) can't be directly bound to a combo box. I expected it to work, but apparently it doesn't (there's no "Source Attribute" you can select). So I think what you need to do is create a Structure with a single Attribute of type Integer, set the local list variable to List of [your structure name], and set the Combo Box's Source Attribute and Source Identifier Attribute to the name of the Attribute.

Cannot make it much easier ;-)

Kilian Hekhuis wrote:

Hi Manish,

The "loop widget" doesn't work like that. A For Each (the official name) loops over the content of a list. You can set the start and maximum number of enumerations, but if the list is shorter than that (and in your example it is empty!) there will be no iteration.

What Karthik needs to do is manually create a loop with an If, a variable that starts with 1905 and is incremented each loop, and a ListAppend, like this:

You are just initializing the var each time or did you have an if construction in mind, always dangerous to do something just by mind and not trying the solution if it really works ;-) this will just get him a very long list of 1905's ;-) and an iis server crash ;-) on my first try i got a long list of years starting at 1 because i forgot to initialize the struct item right with 1904

But all is just basic stuff, finding this our yourself as a beginner and trying stuff is what gets your experience right, we are too friendly to help Karthik every step of the way he should try himself... ;-)


Hi Wim,

Yeah, in retrospect my code isn't completely correct. That'll teach me to try to quickly help someone :). And yeah, it's all pretty basic stuff, that's why I'm always wary of producing the detailed stuff you gave him :).