id is saved instead of text from a combobox

id is saved instead of text from a combobox

  

Hi,

I have a combobox loaded with certain list of values and I want to save the text of the combobox to a text attribute in my entity. on the save action, it saves the id of the combobox to the database but I want the text of the combobox to be saved in the database. How to do it? Can some one help? 


Appreciate quick responses. 

Arun.K.S

Solution

Hi Arun,


Why don't you query the same entity that filled the combo box to lookup the text value?

Either that, or if you are using creating a custom list to fill the combo box (that is not from an entity on the db) you could have a Text Id that is the same as the Text Value.


Regards,

João Rosado

Solution

Hi Arun,

Did you try approach suggested by Joao? Let us know if you need more help.

João Rosado wrote:

Hi Arun,


Why don't you query the same entity that filled the combo box to lookup the text value?

Either that, or if you are using creating a custom list to fill the combo box (that is not from an entity on the db) you could have a Text Id that is the same as the Text Value.


Regards,

João Rosado


Could you explain how to do this? I have a combo box selecting its options from the correct static entity, but I want to store whatever the user selects into text variable, not as an identifier. Thanks!


Arun Selvarangam wrote:

Hi,

I have a combobox loaded with certain list of values and I want to save the text of the combobox to a text attribute in my entity. on the save action, it saves the id of the combobox to the database but I want the text of the combobox to be saved in the database. How to do it? Can some one help? 


Appreciate quick responses. 

Arun.K.S

Hi Arun,

I assume you are using static entity, you can achieve this by doing

Change the Id type to text, 


Then Specify the id value, 

Hi Arun,

you might also want to check this other post on the same subject. Typically I'd advise against storing the Label instead of the Id of a Static Entity (as you may read on my last reply on that post), can you explain why you need this?

Hi Arun,

I will endorse what was already told about being a bad practice to store labels when you have an Id, as it seems to be the case.

As an alternative approach, if you need the label and wants to retrieve it directly as the output from the combo box, you can do the following:

1. In the preparation, add an aggregate that have as source your static entity.
2. Add a computed field to the aggregate, and set its formulae to be equal to the label of the static entity.
3. Add the aggregate list as source to the combo box (Source Record List)
4. Add the "Source Attribute" to the new field of the aggregate
5. Add as "Source Identifier" the new field of the aggregate (or any other field you see fit).

Now when you select a value, it will be set in the variable bound to the combo box.

The "new field" trick is required as if you use a normal field of the aggreate, it does not allow you to select which field value will be stored in the variable.

I think maybe the output structure of a SQL can also have the same effect (if not an entity).

In any case, this is "unusual"...

Cheers,
Eduardo