combobox question

combobox question

  
Hi, 

I have 4 tables:
a) campagnes b) recorddefinition c) recorddefinitiondetails d) messagerows (berichtregels)

a campagne has one recorddefinition and several berichtregels. a recorddefinition has several recorddefinationdetails. The recorddefinationdetails has columns named kolomnaam and datatype. (part of the) ERD included as attachment.

Q: How do I populate a combobox for a field in table d (berichtregels) phonenr (call_telefoonnr) where the values in the combobox are the values in recorddefdetails.kolomnaam that match datatype phone (Bel). I saw some tutorials about the combobox, but I cannot seem to work it out for this particular case. 

Regards, Harry
Hi Harry,

To populate a combobox on a table you need to create an action that ouputs the list of elements you want on the combobox and set that action as a function. Then you can bind this function's output to the combobox.

Cheers
Hi André,

That's really what my question was (maybe not rightly put): how do I output the list, must I use a(n advanced) query for this, maybe you could explain it is a step by step answer? I followed the tutorials of quering, but I'm a bit stuck on the approach I must follow now.

Regards, Harry

 
Sure thing.

If you went thru our online training there's a module for implementing business logic and output data from actions. There's one setting for these actions that converts them into functions.

Now what you need is that the output of this action to be a record list of the record definition you want. Than you can bind this on the combobox as the source record list, similiar tho this example but using the function instead of a query.

Cheers
Hi André,

after reading through the help and showing trainings modules (yhanks for pointing some out to me) I came up with a -somewhat different- approach to do a SimpleQuery in the preparation of the form. The values are shown correctly but the values are not correctly saved in the field (also I/m getting a warning). I must be doing something wrong, but I can't quite figure it out. Could you take a look (oml attached) Choose Testcampagne1, Berichtregel 0 RegelType Bel, you can see that the combobox has the right values (I tested that with another campagne pointing to a different recorddef - other values there as excpected). What am I missing/doing wrong?

Regards, Harry
Your warning is because you haven't pointed the right Variable to save your result.

The Source of your combobox is GetCampagnesByRecordDef, but the Variable to save it can't be the source table (this is why you aren't saving properly).



I would say that if your combobox returns a Campagne, you should save it to campagne field. Something like this.



See if it works like you expected.
Hi Nuno,

Well, I guess that my naming of the query put you on the wrong track - my bad. I now renamed it to GetKolomnaam4Telefoon. I want to populate the combobox with the values of Kolomnaam (that works) and save the selected value to table Berichtregel field Call_Telefoonnr. However I cannot select that from the variable property. I get an error message (attached).

Regards, Harry   
Has the error message says the datatype of your variable is wrong. Combobox can be tricky. Although you show the name the value store on the variable is the identifier, so your variable should be of type RecordDef_Detail Identifier.
Hi André,

Yes that's what the error message says, but of course that's not where the value is to be saved/stored. So I'm a little bit stuck on how to do this.

Regards, Harry
Hi Harry,

Unfortunately dutch is not my forte, I can't figure out what you are modeling by looking at your eSpace module :(
What exactly do you want to store in berichtregel? Shouldn't you have a RecordDef_Detail FK there?
Hi André,

I will try to explain:

A campagne has a recorddef, which has recorddefdetails. It describes what the recordstructure is of the structure that is used for the campagne to send messages. The field kolomnaam (column_name) can hold for instance the values   'phone_mobile', 'phone_home', both of DataType telefoon -where DataType is a static enttity). A campaign also has one or more Berichtregel(s) that holds the message(parts). In the field Berichtregel.Call_Type I want the user to select in a combobox the values in recorddef_detail that are of type Telefoon (so for ex. 'phone_mobile'). Our telephony platform reads the database and can determine which column to use ('phone_mobile') to call or sms

Regards, Harry
 
Two options then:
  1. Use the special list of the combobox and the special list variable. As documented here. On the special variable you put the field that you want the value to get stored.
  2. Keep using the combobox as you have and bind the combobox's variable to a local variable of the corresponding type. On the save action get the corresponding record from that identifier and store the value.

Hi,

Option1 I cannot use I think because the combobox is filled dynamicly (and not in development) Option 2 I choose the type for the local var as RecordDefDetail Identifier (because if I use text the same error is shown as I before showed in this post). Then I assign the var tot the field in the save action. But the value is not saved. I expected this because the var is of the wrong type. So still stuck at the same point it looks like. 

Regards, Harry
 
  1. Create a local var on the screen of datatype RecordDefDetal identifier
  2. Bind this local var to the variable property of the combobox
  3. On the Save action use this identifier to get the label of that RecordDefDetail with a simple query
  4. assign the Naam of this RecordDefDetail to whateve field you want it in the Berichtregel

Hi,

I created a little testmodule in English (oml attached) with only the tables and attributes that matter, where (comment in the diagram ERD) I explain what I want. Could you look at this and show me how to make it work?

Regards, Harry


HI André,

I took me a little while to understand 3 and 4 in the save action. but now I got it. Thank you for pointing it out.

Regards, Harry
Glad I could help :)
Hi André

I'm sorry that I have to come back to this. It seems that there are a few side effects that are not right. The message on saving the Berichtregel that is generated by Outsystems is wrong (shows the value of the saved field instead of the id of the berichtregel) and when you want to edit the record again the value of the first item in the combobox is shown instead of the actual value.

Could you take a look? Completed OML attached.

Regards, Harry  
HI André,

Did you had the chance to look at this. I'm stuck.

Regards, Harry
Harry,

Seems to me that you're skipping some steps. It is ok to use the scaffolding capabilities of the OutSystems Platform but you need to understand what is going on behind the scenes or you'll get stuck :(, my advise is that you go throught the online training.

The message shown when you save the record can be changed by you. Check out this video.
As for the combobox it is the variable assign to it that determines the selected value, i.e. you'll need to iniitalize this variable in the preparation for the editing use case. Again refer to the combobox widget documentation, I know this widget is a little bit tricky...

Cheers

Hi André,

I read the documaentation and watched the videos -again- but (all other things are sorted out now) still cannot get the combobox to display the attribute value in the database as I open the screen, In the preparation I assigned the variable but still no luck.

OML attached

Regards, Harry
You need to do the inverse process you did before. You need a query to get the ReportDefDetail from the Naam value, and then assign the Id to the Var1 variable. This would be much easier if you'd store the id and no the label....