Entities with Text Identifiers

Entities with Text Identifiers

  
Hi everyone,

My architecture need is to have a functionality where the user can choose the format hour between UE standard and USA standards. In our application, the user selects the hours using a combobox that displays hours in 30-min intervals.

Our first naive approach was to use translations but that is too much error-prone. So, we have to find a centralized way to achieve that.

Our alternative was to create a static entity with these values (let's call it "Hours"). But, as we already have a text variable associated to every combobox and that logic is everywhere, I thought we could eliminate the default id and set the id a value text.

Surprisingly, outsystems requires to associate an "Hours" id and doesn't accept a text variable. This is troublesome because means a lot of rework.

Any ideas on how to surpass this? Shouldn't a text variable be enough?
Hi Carlos,

Tecnically, yes it would be enough. But In terms of language it would break the concept separation of being a Id or not.
Just like there are no implicit conversion between EntityTextIdentifier to Text, you can't use a Text variable to hold a EntityTextIdentifier.
Breaking that separation needs to be a explicit and conscient decision of the developers, so we enforce the use of the EntityRefTextToText action if they really want to do the conversion.

This prevents common errors and mistakes from developers.
For example, assigning manually a value to the text variable is easy. If then it was set as variable of the combo-box then it could be a invalid id for the Hours entity (if it didn't match any). Forcing the type to be Hours Identifier forces the sets to use either 'Entities.Hours.*' or explicitly write 'TextToEntityRefText("something that may not be a valid id")'.


That said, I would create a action that recieves a Id and returns you the transformed hour in a Time variable.
Then fix the usages to use it.
May cause you a bit more of work now, but in the long run it lowers the costs of maintaining the application


Note 1: I would have it already as Time in the static entity, not use Id conversions.
Note 2: Remember that the 'GetHours(idVariable)' operation is always cached, so doesn't make database requests. So it's pretty efficient to get other attributes of the entity.

Regards,
João Rosado