Hi. I'm creating a simple CRUD form to test out a new REST API. When I imported the API, a Enum was created as a Database entity. What is the simplest way to use that enum as the options list in a dropdown widget?
Thanks!
Hello,
The easiest way is to use the data as the dropdown input and use ENUM as the value to present to the user.
I leave a link with everything you need to know about the dropdown.
https://success.outsystems.com/Documentation/11/Reference/OutSystems_Language/Interfaces/Designing_Screens/Dropdown
Regards,
Jorge Rodrigues
Hi Marc,
You can do this very simply in three steps:
1. Create a variable of the type of the entity whose records you will be displaying in the dropdown. In my case, I will be showing users, so my variable will be of type User Identifier:
2. Add an aggregate that queries your entity whose records you want to display. In my case, the entity is Users:
3. Add a dropdown widget to the screen from the left pane and configure its properties, using the variable in 1. and the query in 2.
Kind Regards,João
Thanks João. Only problem is that my entity is static. It was generated by Outsystems when I imported the swagger JSON. When I try to aggregate, it says 'Enum_TroubleTicketStatusType' is defined in an integration or in a Library module and cannot be used as an Aggregate Source.
Ah! In those situations you cannot consume it.
What I usually do is to not expose to other modules the structures coming directly from REST APIs. I add my own public structures which abstract the effort of converting data values and such.
Not to mention that I usually do not create my foundation modules as library to avoid this kind of limitations, I usually create them as services (if no client actions are needed like in the case of connectors).
As such, in those cases I create my own public static entities with the possible values to be used by the consumers.
This is to promote the decoupling of the business rules from a third party integration.
Just want to reiterate what João said: Use service modules to consume/expose REST APIs and normalize the data coming from the APIs to ease the maintenance and re-usability of that data.
Also, are you using a library module for any reason in particular?