Combo Box Widget

Connected to Exercise "Data Queries and Widgets II" in the Developing Web Apps course.

I have a combo box purposed to display the various roles for a movie.

It's properties are set thus:

- Variable | role id of the local data variable

- Source entity | Person role

- Source attribute | Label

I understand the the values from the source attribute are displayed in the list of options in the combo box.. which in this case is "Label" attribute of the Person Role entity.

And, I reckon that it is the role id that is to be posted to the database (not the label, the label is just for user-friendly ui).

What I do not see is how is the role id associated with the variable and thereby posted to server? i.e. When the user selects a "label", how is its associated role id added to the local variable and then posted to db? i.e. I don't the the settings for this anywhere.

** for those who did answer my questions in the past you can tell that I desire to link the link between all objects and functions; therefore my question thus.

Hi David,

When you set an entity as Source Entity, OutSystems assumes (and expects) that the Variable is the same type as the Primary Key (Id) of the source entity. So PersonRole Id in that case.

Then for the Save action, you need to pass that variable to server. It can be a variable of the Form object (PersonForm.Record.Person.PersonRoleId) or a stand-alone variable. So that's the step where variable is passed to DB.


These are actually enough for the platform to determine the relation of the selected "label" with its Id. There is frankly no direct answer to your question, it's just the "magic" that happens under the hood. And not just OutSystems magic, but .NET magic since OutSystems uses .NET Framework. It might be utilizing the SelectedIndexChanged event of Combobox.

Thank you Oznan.

What I gather from you answer is that there is no property for the combo box widget in which the value for the variable can be set - because by "magic" (under the hood) it is set to accept just the id of the selected record of the source entity and this cannot be changed to any other attribute; i.e. the value in the set variable is automatically bound to the id of the selected record in the combo box..

.. for which cause the data type of the variable must be the same as the data type of the id of the source entity.

Did I comprehend correct?

If yes, then I think there ought to be a non-editable property in the combobox widget after 'variable' property, named 'variable value' and set to the id of the source entity. This would make it more self-explanatory and help connect all the dots.. not to mention can help in debugging too.

Hi David,

I hope I understand you correctly. You can actually set the Variable to a value you want in Preparation, so that when the page is loaded, the combobox will be "pre-selected" with that option. The value you are assigning should be of the same type as the Source Entity's Id indeed.

As you might have seen, there is also "Special List" and "Special Variable" for comboboxes, in case you don't want to use an Entity as the source, but a list you created. That might suit your needs better for some cases.

https://success.outsystems.com/Documentation/11/Reference/OutSystems_Language/Traditional_Web/Web_Interfaces/Designing_Screens/Combo_Box_Widget

Thank you for the reply Ozan.

What I meant is - the combo box widget's variable property can be set in the properties section of the widget, but there is no setting within the properties section to set what value shall be stored in that widget which was leaving me blur in terms of connecting the dots.

I can select the source entity and attribute to populate the combo box, but because there is no property to set the value in the variable of the combo box, I could not see what value was going in there and thereby what value was posted to server.

Then you said that the id value of the selected record of the source entity is what goes in the variable and posted to server... and this happens under the hood.. to which I responded that OutSystems should add another property titled "variable value" to help connect the dots and let the devs see wha value is going into the variable even if it be obvious to some.


Hi David,

I think I would put it as "the type of the variable is (should) be the same as the Id attribute of Source Entity (so that combobox works as expected)". Type cannot be changed by assigning another value.

By default, the value of the variable is null, as long as you don't give it a default value in properties section or assign a value in Preparation. That's why when you open the screen, combobox is displayed as nothing selected.

Hi David,

so yes you understand correctly, Outsystems assumes that the selected value will be of type EntityIdentifier, so no need (and actually no possibility) to set it yourself as a developer.  

I do agree with you that it would be nice if it were mentioned as a property in the property pane as greyed out and unchangeable 'Source Identifier Attribute'.  

When you choose an Entity as source, you can still easily know that it will be that identifier, so not much need for that extra bit of info in that case.

But you could have a Record List as source, and in that case, maybe the name of the list doesn't easily reveal what will be the identifier, so you'd have to look in the aggregate feeding the list to understand what type your local variable has to be.

I wouldn't hold my breath for this, though, as it only exists in Traditional Web, I can't see OS doing any improvements on that type of application.  

In Reactive, there's no combobox, but a dropdown, and in that widget, OS also tries to guess what you would want as selected value, but as a developer, you can choose something else.  And to make things even easier, you don't have to define your local variable yourself, you can let Service Studio create a local variable of correct type for you with the 'New Local Variable' option.

Dorine

Hi Dorine, and thank you for your elaborative reply.

You've seen my questions in the past and already reckon by now that I seek to connect the dots.. and your reply was quite helpful.

mvp_badge
MVP

Hi David,

Take a look at the rendered combo box control in the browser Inspect > Elements section. You can observe that the combo box options are rendered as HTML option tag, and each option tag has a property called value that holds the respective record Id value. i.e. in the below example option tag value = DesignationId 

So, whenever the user select the combo box option (i.e. Label) the mapped variable retrives the respective selected option tag -> value attribute value ;p

I hope this helps you!


Kind regards,

Benjith Sam

Hi David,

When you set an entity as Source Entity, OutSystems assumes (and expects) that the Variable is the same type as the Primary Key (Id) of the source entity. So PersonRole Id in that case.

Then for the Save action, you need to pass that variable to server. It can be a variable of the Form object (PersonForm.Record.Person.PersonRoleId) or a stand-alone variable. So that's the step where variable is passed to DB.


These are actually enough for the platform to determine the relation of the selected "label" with its Id. There is frankly no direct answer to your question, it's just the "magic" that happens under the hood. And not just OutSystems magic, but .NET magic since OutSystems uses .NET Framework. It might be utilizing the SelectedIndexChanged event of Combobox.

Thank you Oznan.

What I gather from you answer is that there is no property for the combo box widget in which the value for the variable can be set - because by "magic" (under the hood) it is set to accept just the id of the selected record of the source entity and this cannot be changed to any other attribute; i.e. the value in the set variable is automatically bound to the id of the selected record in the combo box..

.. for which cause the data type of the variable must be the same as the data type of the id of the source entity.

Did I comprehend correct?

If yes, then I think there ought to be a non-editable property in the combobox widget after 'variable' property, named 'variable value' and set to the id of the source entity. This would make it more self-explanatory and help connect all the dots.. not to mention can help in debugging too.

Hi David,

I hope I understand you correctly. You can actually set the Variable to a value you want in Preparation, so that when the page is loaded, the combobox will be "pre-selected" with that option. The value you are assigning should be of the same type as the Source Entity's Id indeed.

As you might have seen, there is also "Special List" and "Special Variable" for comboboxes, in case you don't want to use an Entity as the source, but a list you created. That might suit your needs better for some cases.

https://success.outsystems.com/Documentation/11/Reference/OutSystems_Language/Traditional_Web/Web_Interfaces/Designing_Screens/Combo_Box_Widget

Thank you for the reply Ozan.

What I meant is - the combo box widget's variable property can be set in the properties section of the widget, but there is no setting within the properties section to set what value shall be stored in that widget which was leaving me blur in terms of connecting the dots.

I can select the source entity and attribute to populate the combo box, but because there is no property to set the value in the variable of the combo box, I could not see what value was going in there and thereby what value was posted to server.

Then you said that the id value of the selected record of the source entity is what goes in the variable and posted to server... and this happens under the hood.. to which I responded that OutSystems should add another property titled "variable value" to help connect the dots and let the devs see wha value is going into the variable even if it be obvious to some.


Hi David,

I think I would put it as "the type of the variable is (should) be the same as the Id attribute of Source Entity (so that combobox works as expected)". Type cannot be changed by assigning another value.

By default, the value of the variable is null, as long as you don't give it a default value in properties section or assign a value in Preparation. That's why when you open the screen, combobox is displayed as nothing selected.

Hi David,

so yes you understand correctly, Outsystems assumes that the selected value will be of type EntityIdentifier, so no need (and actually no possibility) to set it yourself as a developer.  

I do agree with you that it would be nice if it were mentioned as a property in the property pane as greyed out and unchangeable 'Source Identifier Attribute'.  

When you choose an Entity as source, you can still easily know that it will be that identifier, so not much need for that extra bit of info in that case.

But you could have a Record List as source, and in that case, maybe the name of the list doesn't easily reveal what will be the identifier, so you'd have to look in the aggregate feeding the list to understand what type your local variable has to be.

I wouldn't hold my breath for this, though, as it only exists in Traditional Web, I can't see OS doing any improvements on that type of application.  

In Reactive, there's no combobox, but a dropdown, and in that widget, OS also tries to guess what you would want as selected value, but as a developer, you can choose something else.  And to make things even easier, you don't have to define your local variable yourself, you can let Service Studio create a local variable of correct type for you with the 'New Local Variable' option.

Dorine

Hi Dorine, and thank you for your elaborative reply.

You've seen my questions in the past and already reckon by now that I seek to connect the dots.. and your reply was quite helpful.

Hi David,

Hope you are doing well.

as you said, "What I do not see is how is the role id associated with the variable and thereby posted to server? i.e. When the user selects a "label", how is its associated role id added to the local variable and then posted to db? i.e. I don't the the settings for this anywhere. "

Yes ofcourse, we don't given any setting for this. Because in Static Entity each "value" is a Record. The Record Identifier can be used in place of the Static Entity Id. When you created Records it will link with Label and that label uses source entity Id to identify record. So as in Combo box widget, variable property holds PersonRole Id and when you select some label options from UI using that combo box, the "PersonRole Id" is directly uses Record associated with that Label PersonRole Id and it selects that particular label to show that value in Text(Label contain) associated with that source entity Id you have selected. Its created in design time at Service studio that's why we don't have to give external setting for this. Sharing screenshot, here Source entity Id (PersonRole Id's) created and this values link to Label attribute that uses records inside Records folder. 

Regards,

Shubham

Screenshot82LI.jpg

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