Hi! 

I am developing an application where I will need to add text to or change the answer of the user based on the answer. 

So for instance if question 1 is answered with: A
I need the value in the database to be: Situation A applies for.... 

It could also happen that I want an answer to be changed completely. So if the answer to question 2 is Yes, I need it to become something like: Instance X uses application Y..... 

Is there a smart way do this within Outsystems? I have done it once in SQL server with a lot of case when and concat statements, but I am guessing there should be a better way of doing this.

Hi Max,


First of all, the user answers and their applications are static?

If yes, you can map that associations in a associate table where you can put in a record the Answer Id and Application ID. If you don't want to have duplicates don't forget to create an index with that two attributes and set it as unique.

Then, when you want to change user answer consulting that table, retrieving the correspondent change that you want.


This can help you?


Best regards,

Ricardo M Pereira

Hi Max,

There's unfortunately nothing out of the box. Personally I often use something like this:

Replace(Replace("Instance {0} uses {1}", "{0}", Instance.Name), "{1}", Instance.Use)

but it's kinda convoluted, and I wish OS would support something like that out of the box.


Why would you want to change the content of the answer? Why not hide the answer and show a new expression with the content you want to display? 

I also create a game/quiz application and we made a data model where the "gamemaster" can create the game themselves. For each answer they could add an explanation text. This text is shown after answering the question. This worked very well and gave the "gamemaster" a lot of freedom and flexibility.  

Perhaps this approach can also be applied to your use case? 

Ricardo Pereira wrote:

Hi Max,


First of all, the user answers and their applications are static?

If yes, you can map that associations in a associate table where you can put in a record the Answer Id and Application ID. If you don't want to have duplicates don't forget to create an index with that two attributes and set it as unique.

Then, when you want to change user answer consulting that table, retrieving the correspondent change that you want.


This can help you?


Best regards,

Ricardo M Pereira

Hi Ricardo,

Thanks, I thinks something like this might work! Will let you know when I tried. (Might take a while since I am currently developing something else but wanted to do some research)


Vincent Koning wrote:

Why would you want to change the content of the answer? Why not hide the answer and show a new expression with the content you want to display? 

I also create a game/quiz application and we made a data model where the "gamemaster" can create the game themselves. For each answer they could add an explanation text. This text is shown after answering the question. This worked very well and gave the "gamemaster" a lot of freedom and flexibility.  

Perhaps this approach can also be applied to your use case? 

I need to add text to an answer or create a whole new sentence based on the answer, but only for the maintainer to see. The user filling in the questionnaire should not see any changes.

My questionnaire has questions that look like this: 

Q: Do you live in Europe? 

A: Yes
A: No

When answered with yes, the outcome needs be something like this: Person X lives in Europe.


Yeah, but you wouldn't want to store that in the database. In the database, you store the Boolean outcome of the Yes/No question, and then you create an Expression that formats that to what you want.

Max,

I created a small Demo for you that shows how to implement a custom text based on a boolean value. This should help you get up to speed.

You can watch the demo in action here: https://vkoning.outsystemscloud.com/BooleanDemo/Demo?_ts=637213287770935439

I also attached the OML