Combo Box - pass the display value instead the id

Combo Box - pass the display value instead the id

  
Hi!

I have an Edit Record where i added a combo box based on an entity. Very nice.

Now I want to, when select a record in this combo box, pass the display value instead the id. Is there any way to do this?

Thanks
Cool! This helped!

Here's the step by step solution:

1. Add/Remove Reference "Text" (if you not have);
2. At the Preparation, add a Advanced Query;
2.1 Set Text as the Output Structure;
2.2 Set SQL as "SELECT {ENTITY NAME}.{FIELD NAME} FROM {ENTITY NAME}";
3. At the Edit Screen, add a Combo Box;
3.1 Set Name;
3.2 Set Variable as [EditRecordName].Record.[EntityName].[FieldName];
3.3 Set Validation Parent as [EditRecordName];
3.4 Set Source Record List as [Name of Advanced Query].List;
3.5 Set Entity/Structure as Text;
3.6 Set Source Attribute as Value;
3.7 Set Source Identifier Attribute as Value;

And that's it!

And if the field is not mandatory, and you want to add an empty string option, you can redefine the advanced query as:
"SELECT {ENTITY NAME}.{FIELD NAME} FROM {ENTITY NAME}
UNION SELECT ''"

Many thanks!
Hi Armando,

I'm trying to do something like that, but I have 2 questions:
ad 1: How can I Add/Remove Reference "Text
ad 2.1 How can I Set Text as Output structure

p.s.
In the combobox I would like to see more that one attribute (for example Name and Address).
In the advanced query I already get all the results I want, but how do I get these results in the combobox?
Or do I just get that result by implementing the above?

Regards,
Arnold Grippeling
 
Hi,

I would suggest that you checkout this academy video to understand how the combo box works.
Also, check this Service Studio help topic, because it contains some tips on more advanced topics.

Arnold, regarding your questions:
If you notice, Armando's advanced query is only fetching a single column from the database, so you just need to:
  1. Create a new structure
  2. Add a new attribute
  3. Change its data type to text
  4. In your advanced query, use the new structure as output parameter (right-click the output structure folder)
If you need to better understand how advanced queries work, you can check this academy video, that covers this part of the output structure.

Now, if you want to display more than one attribute in the combo box, you need to make your query concatenate the information you want, and then bind the combo box with that query. I'm sure that if you see the combo box video, it will be clearer.


Thanks for the reply.

However I already used these 2 videos to structure the logic. And tried to set it up likewise; I also have found some topics on the forum that handles this question. On this point I 'believe' I've set it up as it should be; nevertheless no results in the combobox then the single column, being the assigned attribute.

If you notice, Armando's advanced query is only fetching a single column from the database, so you just need to:
  1. Create a new structure -> DONE (KlantNaam, using the attributes of Klant)
  2. Add a new attribute -> I don't understand
    I have 2 entities, namely Kind (Child) and Klant (Parent) which I have to connect using the combobox
  3. Change its data type to text -> probably makes sense when I grasp the previous bullet..
  4. In your advanced query, use the new structure as output parameter (right-click the output structure folder) -> done that (KlantNaam)
Now, if you want to display more than one attribute in the combo box, you need to make your query concatenate the information you want, and then bind the combo box with that query. I'm sure that if you see the combo box video,
-> I've set up an advanced query at preparation (Kind). I believe that's where I have set the columns to show (concatenate?). When I run a test I get the results I want. However on the combobox it only shows the attribute set as source attribute.

Hope this helps to make my problem more clearer.

Regards,
Arnold

Edited by André Vieira on request of user to remove attachment.

Hi,

I'm not sure if I understood correctly your problem. Check my changes to your eSpace to see if I got it right.
I changed the screen and the preparation.

Edited by André Vieira on request of user to remove attachment.
Yep, that's indeed the solution.

I didn't understand the 'text' part in the structure for Klantnaam. As I see now the attribute text contains all data as set in the advanced query (SQL). And then set Text as the source attribute for the ComboBox
And to store Klant to the specific Id you connect it to the 'edit page variable KlantId'.

Thank you very much!

Arnold
Hi, 

The combobox works perfectly for all text attributes. However, if I would also like to display a date attribute in the combobox I get an error.
Is there a way to solve this?

Regards,
Arnold
 
Hi,
 How to add subsections inside a combo box.For eg  if i have the Electronix as my
first list then under Electroninx i need to add subsections like Laptop,Tv,Refrigreator.How can i do this.Is there any way of doing .

Regards,
ChandrasekarRadhakrishnan
Chandrasekar Radhakrishnan wrote:
 
Hi,
 How to add subsections inside a combo box.For eg  if i have the Electronix as my
first list then under Electroninx i need to add subsections like Laptop,Tv,Refrigreator.How can i do this.Is there any way of doing .

Regards,
ChandrasekarRadhakrishnan
 Duplicate answer to a duplicate post :P

Since its not a tradicional combobox (html select), you'll have to implement your own component, using webblocks and javascript, and it will need a little work... (check this post). Please, dont forget to share this on forge if you do! :)

You can try a workaround too, using the Search and AutoComplete component, that is very customizable and easy to use.