I have just spent 6 hours struggling with the utterly trivial task of generating the text to put into 3 dropdowns.
Experienced users of Outsystems can scoff, but I want to explain the unexpected difficulty in doing this trivial thing so slowly when Outsystems helps to do very hard things speedily.
Being a trivial task I assumed I could put the text (which is to be generated based on earlier events) into a text variable and put the name of that variable in the properties box of the widget.
No, not that simple. Why not?
Okay, so maybe not a text variable. How about a list of text?
The properties box accepts the name of this variable, but then asks the unexpected question of where to find the text that is to be displayed.
Um, it's a list of text. Surely, clever software like Outsystems can manage this.
No, apparently not. When trying to display a list of text, it seems that the software can't use a list of texts as an input.
I couldn't find anything in documentation or the forum addressing this specific problem. The examples all seem to be dragging stuff from the database, not using text generated at run time. A few questions had been asked on the forum, but with no explicit answers.
Curiously, and this was deeply confusing, the Content box would accept "What's going on?" as a valid entry, but would not accept the name of a text list.
It seems that the box requires there to be a sub-unit such as TextList.thisText rather than just a list of texts. I was confused by this.
So, I set up a structure and this seemed to be accepted. Why does the widget need a structure? Does it need a structure, or was I mistaken?
This seemed like an unneeded complication. I assume there is a good reason, but I can't imagine why the widget can't just accept a comma separated text variable or failing that a simple list of texts. Did I miss something here? Is it actually simple?
Now, how do I construct a list?
Well, I have already done that to create datapoint lists for a chart, and so I know to use ListAppend and ListClear. But they are on the server. I didn't see them available on the client. (Found out many hours later than they can be brought into the client. Knowing that in advance would have been nice)
When I built the logic on the server I then had a bizarre problem that the format that was delivered from the server as an output variable seemed to not be the format required by Assign on the client. This became so confusing that I would have to go through my test notes to even try to explain.
I don't know if I did this right, but I was surprised that ListAppend doesn't have boxes to define what the new thing is to be appended. It seems to need a variable and never a literal.
So, my logic has an IF statement that if true the action is to add "18-39" to the list. To do this requires a variable and an ASSIGN and then a LISTAPPEND, rather than just a LISTAPPEND with a box where I have typed the value "18-39" to append. I can type that value into a box on ASSIGN, but not skip that and just type it into APPEND?
It was around then that I found in the documents on lists that these list functions can be added to the client by adding a dependency. (So many things that can be done, if you know about them.)
Now I had the tools in the right place. Figuring out what variables to use and how to get them properly declared took a while. (text, structures of texts, lists of structures of texts, lists of text???)
Building the logic to generate the text went smoothly. The biggest hurdle was in the complication of having to have these structures that the widget requires, and getting confused between text, text in a structure and lists of such structures.
Outsystems makes very complicated things easy, but it also seems to make some very simple things hard.
This is written from someone who has now had about 150 hours of using Outsystems. I may have completely overlooked, or been unaware, of things that more experienced users take for granted.
Perhaps there is yet another page of documentation I should have read, or a video I should have watched, maybe I even did & have forgotten.
Oddly, most of the time absorbing problems I have had are, like this one, doing trivial things rather than doing the hard things. The hard things have gone much more smoothly.
My app which is an interactive dashboard to interrogate and display national statistics has data, it allows the user to decide which data to display and it graphs some of that. What I am now working on is how the user can decide which of the data should be compared together in which type of graph. It was at this point that I added the dropdowns.
The dropdowns now seem to work.
The next task is to take the user's selection from the 3 dropdowns, convert that into an SQL SELECT and then generate a datapoint list for the charts.
As each of those are things that the app already does I should be able to complete this part, perhaps in less time than it took to work out how to put text into the Dropdown widget.
The above is an experience of dealing with a very large software suite with its own peculiar requirements.
Now you can respond pointing out what I should have read, should have studied, should have done differently...
Or you could discuss what problems you have or had in starting with Outsystems.
Hi Greg
Sorry you've gone through such confusion for such a task.
It's very odd when you select the List as a "Text List", it prepopulates the Options Value, but you get Suggestions as None for the Options Text. I just typed Value in the Box and it accepted it and let me prepopulate it and built the list.
Tbh I haven't seen that in the documentation, sometimes with these things it's just trial and error. The fact you found a different solution for your use case is good thinking anyway. Sometimes these problems just need thinking about differently. The amount of times, that's gone "That should work, why isn't working, perhaps I'll do it this way".
If the List Append is a Text. You can just write text to it. I saw that in a video on Async processes. Wasn't expecting to see it, like you, I thought you needed a variable. You can often expand inputs if a variable is a certain type.
Just keep practicing and these things will come naturally.
Hi Greg,
sounds like a bad day at the office.
Is this :
an invitation or warning not to do it. I'm asking in all honesty cause I can't really tell, and if it is not an invitation, I won't bother.
Dorine
Also,
6 hours of fighting against the tooling sounds very dishartening, running into small "how the heck do you do this" problems, are easily solved on the forum in a matter of minutes, so don't hesitate, ask them before they frustrate you and you go down a rabbit hole you needn't be in.
Hi Dorine,
I would be very happy if you would tell me how to do it, you have been very helpful with clear simple explanations in the past.
I am generating the text to be displayed in a drop-down.
To populate the drop-down can I use a simple text variable perhaps comma separated?
If not, what is the simplest way to populate it?
Greg
(I have a working version, but I assume it isn't the best way to do it)
The funny thing is that I assumed all the way along that it would only take a few minutes to solve the problem. I just needed to... oh, that didn't work... ah, but if I... oh, not that either
No, wait, I can do this... oh, maybe I can't...
It became a challenge, an absurd trivial challenge that I wanted to solve rather than be told the solution. The idea of being defeated by something so trivial was not an acceptable outcome.
As sometimes happens, preparing a clear question for the forum lead to my finding my own solution. I suspect my solution is overly complicated, but it works.
It would be useful for the future to learn the correct way to do it, and showing that on the forum may help others.
hey,
both struggling through something yourself and asking help (as you say, just rubber ducking it to formulate your forum question could bring the AHA) are valid and usefull ways of learning and not time lost, just stop and switch when the frustration gets the overhand.
So I will go through your post, there is a lot in there that could use some clarification, I think.
But let's just start with your initial ask, no, a text variable won't do.
A dropdown takes in a list, so a text variable that, to you and me, might look like a list (comma separated or something like that) is of no use, OS is strongly typed, it will not assume or interprete what list you could possibly mean. So you will at the very least need a list of text.
About text list VS dropdown : A list of text should work, however, OS assumes that most of the time you will want to specify 2 things for every dropdown item, a value and a text. The value being the thing that actually gets selected, the text being the thing that is displayed to the user. What you want, only a single attribute that serves as both, is very rare, you would very typically have a textual attribute of an entity or static as what is displayed, and an identifiying attribute of that same record as the Value.
Because in most cases, these will be 2 separate things, Service Studio assumes that if you choose one of the available attributes as value, you won't want that as your text. So to "help you", it already filters that away from its list of suggestions. That is correct very very often, just not in your edge case where you want value and text to be the same thing.
But the suggestions are just that, suggestions, you can always (try to) fill in whatever you like. So just repeat "Value" in the Options Text box. I absolutely agree with you that this is not obvious/clear for a newby from the user interface. And you can't even double click it to use expression editor.
Thank you for the incredible detail. I have read through it, only understood a part, and will have to take time to work though everything you have written.
The assumption that the normal list would be in pairs of text to display & value to be output makes perfect sense and explains why my list of text wasn't what the widget wanted. I did discover that it would accept a list that was structured as
idText
But I had not got the hint of why that is what the widget wanted. Now it makes sense.
The drop down is displaying the names of attributes in the database. My idea was that I may as well take that as output as it is obvious what it refers to whereas "Option3" would not be.
Also, the reason to get this output is to generate SQL to read that item from the Db so why not use the literal name?
More fool me... I had already coded to generate searches and so I reused the code with small changes and there was no point in using the literal names as the original code was using LIKE.
But I did use it in the IF choices so not a complete waste.
another thing that you need to be aware of, and can cause confusion, is that the way you refer to values of items inside a list, is different for lists that consist of a single basic type than for lists that consist of complex types.
for a list with a single attribute that is of a basic type, such as your text, but it could equally be a list of integer or boolean, and so on, you can not name that single thing inside the list. In property boxes (like in this dropdown property) you can only refer to it as "Value".
Also in code, when referring to the value of the current item, you will say <listname>.Current, without anything further naming.
In complex types, each element gets a name and you refer to it by name. Even just making your list of Text a List of Record, and the record only holding one Text element, will change how you refer to it.
textlist vs single item recordlist in expression editor, for the texlist, you have to refer to Current itself :
textlist vs recordlist as input to dropdown
you can see here that my explanation about the suggestions earlier was complete bs, for the recordlist, despite it already being choosen as Options Value, OS still offers it as a suggestion for Options Text.
So I would classify it as a bug that it doesn't show up as a suggestion for the textlist.
so I know to use ListAppend and ListClear. But they are on the server. I didn't see them available on the client. (Found out many hours later than they can be brought into the client. Knowing that in advance would have been nice)
You can't know something before you know something.
I don't really know if this is stated very clearly in the documentation or courses.
Just a tip when you are looking for something that you think should be there : use 'search in other modules', type something like 'List', and you will see side by side both client and server versions of these systems actions. This is easier then dependency management, cause you don't need to know upfront in what module you expect to find it.
if you don't have it as a dependency in your current module (see column In Use) you can immediately add it as a dependency from here (unfortunately only one at a time)
This is really one of those things that are, how shall I say, "subtle", in Service Studio (i.e. hard to find if you don't know what you are looking for)
So this is not related solely to ListAppend, but to all actions that take a variable of a complex data type (list / record / entity / structure) as input. You can either match it to a whole variable or you can expand it into its parts and match each part separately. For a list that would mean expand to list items, for the other complex types it means expanding into it's individual attributes.
If you want to pass in a variable representing the wole thing, their structure has to be same or similar, because to some extend, they don't have to be a 'perfect' match, and when they are not, Outsystems will ask you for the mapping between them.
If you want to expand to match on a lower level, you do that with a tiny + sign that appears in front of it when you hover over the name. If you hover the plus itself it turns blue, click there.
above is example of a listappendall on a list of text, where you expand the list with the plus. You can do that several times.
below is example of listappend on listofrecord, where you can expand the record to fill in it's parts, you can expand only once here of course.
or combining both, an appendall on a list with complex element in it
Oddly, when I hover over the ListAppend name or the tiny + nothing happens.
I am doing this in the properties panel (lower right of screen).
Also, now that I have the variable dropdowns working well, I want to add a fixed choice drop-down and have no idea how to enter the 5 predefined values. I was expecting an ability to enter these as there is for radio buttons, but there doesn't seem to be a way to just type them into the drop-down.
I tried creating a static entity which allows me to define names and default values, but if I offer that to the drop-down it accepts it and then wants me to choose just one of the attributes rather than all of them.
If I create a structure of ID + text, aside from the complication that it wants a list or a record of lists or a list of records or something, what this doesn't do is populate the variable. I have read on the forum this recommendation followed by the need to then program the assignment to that variable at run time.
Surely, not.
I could use radio buttons, but they take up a lot of space and I am already using dropdowns for the variable choices.
So, how does one create a drop-down with a small number of predetermined options?
well, you have to actually click on the tiny +
So for fixed choice (you mean hard code right there on the spot, right ?) you can make a local list with a ListAppendAll in the OnInitialize (see my screenprints before)
Yes, I did remember to click. Spent some time clicking. Nothing happened. Perhaps I click wrong.On the fixed drop-down I found a way to do it without listAppend or any logic. I worked through various ideas until I found one that worked.
How I did it:Data TabRight click entitiesselect New static EntityRight click the new entitySelect New Record (do 1 for each dropdown option you need)
Properties panel (bottom right of screen)
In Label put the text you want displayed in one optionGo back to top of screen and click the next recordIn the dropdown(You need a variable to store the output)
List Get<entityName>.List
Options Text <entityName>.Label
Options Value <entityName>. <--- I used .Label you could use iD or create another
What this did was create a complicated set of constants in the static entity with a referencing system, and that was accepted by the drop-down as a valid list. It displays the text in the correct order and delivers the result.
All of this, because the widget doesn't have a method for typing into it like the radio buttons have.
Yes,
what you describe is the golden standard, using static entities to represent permantent lists of things inside your code. It is what is promoted by all courses and best practices.
I thought you were looking for something other than this, as some people try to avoid using these because of pricing of Outsystems, every static gets counted towards the total of Application Objects, and Applications Objects are part of the pricing methods.
Intriguing. gif. It promises so much...
I rechecked.
The only + sign I see on my version is the tiny one inside the orange icon. I have hovered and clicked all over the place. I do not see any + or anything blue to the left of the word Element.
I checked that what I am looking at is server ListAppend, so seems to be the same thing you have shown in the gif.
Either I am missing something really obvious here, or we have different versions.
only works if it is still empty, as soon as you assign a variable, you won't get the option to expand anymore
Hi @Dorine Boudry simple text list is not working in dropdown , i had to use custom type but still unable to find solution for DropdownTags . because when i select text list as source it does not show Value and Label Field, I want to select same value for both options.
Now If i try to create Text record list as local variable and assign it as source. but In OnInitialize action when i try to use AppendALLTextRecordList and use text list as source(Getting from API) it does not allow me to select value to append from my text list. now only left is to use for each loop and Single append action, but that's not a good approach. Seems like a bug.
Hi @John Oliver ,
for a dropdowntags widget or a dropdownsearch widget, it is not possible to use a simple text list as source.
Normally, when lists don't match exactly on attributes, Service Studio gives you the opportunity to still use one list as source for another, and let's you 'map', but there is a bug, as you already suggested, in Service Studio / the platform that won't let you 'map' a simple (non-record) list to a record list.
So I'm afraid looping and appending is your only option.
However, for a regular dropdown, it works with a simple text list, are you saying in your first paragraph that you can't succeed at that. If so, can you share an oml ? Or were you only referring to dropdown tags.
Hi @Dorine Boudry For regular dropdown it's working fine. I had to use custom option instead of text only.
Thanks for your quick response. Maybe i will raise an idea for dropdowntags widget Issue.