Display a label of a static entity instead of the ID?
Question
Application Type
Mobile

I have an app with a bunch of Yes/No Buttons. Long story short I need the option chosen to be displayed in the database as a label instead of a Identifier (Yes/No instead of 1/2). Is there a way to do so?

Solution

Can you set the Options Static's identifier as text?

It would identify the Static Option by it's name, and would be saved like that as well.

Go to the Option Entity, Delete the Id Property, and right click on the "Label" Property and click "Set as Identifier."

This way it would save on Questionnaire the label of "Options."

Hi Kristina,


You'll want to add the Options entity (with a join on your Questionnaire entity) to your aggregate. Then you can access the Options entity and it's Label property.

Something like this:

Hi,

You can create a new column with the following formula inside:

If(Question1=1,"Yes","No")

Hi Kristina Lesk,

You need to add the source entity of  foreign key of yes no to the entity where you want to display the Options yes no.

Regards,

Komal

Sorry, I probably should have pointed out that I need to do this for every column except for the Comments column.

@Komal Kumbhar I'm not sure what you mean so I haven't tried your solution. The other ones are not working.

Did you try joining the Options entity for every question? 

I.e.

Hi, Exactly I mean what jeroen said you need to add entity in sources which contains yes no options like in above screen shot ,

That's not the issue, It doesn't work on even on Question1, so I doubt it will work on the rest. Probably I have issues with logic then which prevents it from assigning the correct values. Never mind, thank you all for your help.

Solution

Can you set the Options Static's identifier as text?

It would identify the Static Option by it's name, and would be saved like that as well.

Go to the Option Entity, Delete the Id Property, and right click on the "Label" Property and click "Set as Identifier."

This way it would save on Questionnaire the label of "Options."

Hi Kristina,

From your screenshot, I understand that you are looking at the entity data, not an aggregate, right ?

So there are no joins, you are looking at the raw data in a single entity, in other words the rows in a single table in your database.

So every reference attribute from your entity to other entities (allbeit static or not), becomes a foreign key in the database.  It is the very nature of foreign keys that they only capture the primary key of the referenced table.

So, in outsystems it is a very common thing to have a unique number as id of any and all entities (it is the default way of doing it) and as a consequence, most reference attributes end up as only a number in the data.

This is by design.  Can you explain why you need it to store something else then the id of the option ??  What is it that you need to do with the data that can't be done as it is now ?

Dorine

I have an application with seven questions that have "Yes/No" button each. I need the labels to be visible in database because I'll be displaying the answers in the back office of the app. The solution @Pedro Lemos given has worked. I'm just trying to figure out the logic for saving the information now..

Ok,

if that works for you, that's great.  

But I think you should try to understande that how things are stored in the database, and how you display them to users (in the backoffice or otherwise) are 2 different things.

Maybe learn about aggregates and sql to understand how you can display data to your users in a meaningfull way, even if they are stored across many tables with id fields as foreing keys.

Good luck with your logic,

Dorine

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