Dynamically use answers to create a question

Hi All,

I am creating an app where I need to have logic that can create a question based on a previous answer given by the user. It could be that the user gives more than 1 answer to the 'main' question so there should also be more 'sub' questions. 

My database with questions has a unique QuestionAlias and the answer table has the QuestionId in it.

For further development purposes I also need to create some logic that can use the answer to a specific question inside some output structure (so for instance if I answer Max to the What is you name? question, the output should say: The customers name is Max.) To do this I have tried the Regex server action but it doesn't quiet deliver as aspected. I think that the logic is very close to each other for both issues. 

Could anyone be of help?

Thanks, Max

Hi Max,

Not sure what you expect? Do you want someone to develop this application for you? Did you start coding but run into a specific coding challenge where you need help? Please be more specific in the area where you need help, if you have a problem with your code, you could also share the OML file of the module. This way you get a better help from the community.

Also I see you recently started with OutSystems, did you have time to follow some of the training material at https://www.outsystems.com/learn? This is the best place to go when you start learning OutSystems.



Hi Max,

I think you not only need changes to your logic, but also to your datamodel to support this.  This is a type of problem that you could try to solve in a simple way, but that could quickly get more and more complex as you want to get more and more flexible and versatile with it.

So let's have a stab at it :

1) to be able to relate both output and the appearance and content of subsequent questions, your questions will have to be related to each other, have an order or hierarchy to them, and be grouped in to some sort of higher level that holds them together : an exam or a survey or ... entity, relating questions to each other and possibly to the person answering them, and maybe something else to distinguish if the same person could take the same survey more than once.

2) if that is established, you will have to model that certain answers can serve as content for either some sort of outputs, or for other questions.  

For a simple version, where you only control the appearance of a whole question based on an entire answer, or you use the value as an entire answer, you can add a relation entity ConditionToShow between one 'followup' question to another 'precursor' question, and as attribute the answer that should have been given to the precursor question in order for the followup question to appear.  You can have another simple entity holding 'information' that you use in your application, with a foreign key to the question whose answer you want to use for it.  The 'information' entity could hold the default string to display as long as that particular question isn't answered yet for this particular 'survey' or 'exam'.

For more complex, you could go into 

  • maybe only part of an answer is relevant
  • maybe several possible answer values are ok
  • maybe you want to use (part) of an answer inside a question, needing to substitute placeholders
  • maybe answers to several different questions play a role

All of this will lead to more complex datamodel, more complex decision logic, more complex string manipulation

Hope this gives you some ideas,