Should the datatype of an Id attribute within a structure be set to long integer or Entitiy Identifier when it comes to Outsystems best practices ?Thank you in advance
I would say it is personal flavor, though it is more convenient to use the Identifiers because you do not have to use the LongIntegerToIdentifier or TextToIdentifier actions. Personally iam using the identifiers as well, but sometimes I wonder if using corresponding Long Integers to Text data types would be more suitable.
My thoughts are to use Identifier whenever the structure is then used towards entities. I call this "closer to data" and to use the non identifier equivalents when exchanging data with modules higher in the hierarchy e.g. frontend. Entity references (thats what you get when using an identifier in a structure exposed to another module) are soft references, but nevertheless there is reference. So i wonder myself if using non identifier data types could be a good alternative, despite the conversion.
Dear Stefan, I appreciate your response. I've been pondering over the same questions myself. I turned to Long Integers to circumvent unnecessary references, but I've found that in certain scenarios, this approach is decidedly less practical. For now, I'll keep the discussion open and see if anyone can shed light on best practices. Perhaps, as you mentioned, it ultimately boils down to personal preference. RegardsThibaut
Hi Thibaut G ,
Below link for documentation.
https://success.outsystems.com/documentation/11/developing_an_application/use_data/use_structures_and_records_to_create_compound_data_types/?_gl=1*1gpqlk0*_ga*MTE0MzUzODgyNi4xNzAxMTQ5NzU4*_ga_ZD4DTMHWR2*MTcwNzg5Nzk3Ny4xNzQuMS4xNzA3ODk4MzkyLjUwLjAuMA..
As per the above doc , It is recommended as to create entity Identifier.
Regards,
amreen
Hi Amreen,Thank you for the reply !
While reviewing the example provided in the documentation, I noticed the use of an Entity Identifier datatype within the structure. While this could suggest the importance of utilizing Entity identifiers, I remain unconvinced that this example aligns with the best practices so i will leave the discussion open for now
regards
Thibaut
Hey @Thibaut G
As @Stefan Weber already explained I also tend to use long Integer or Text When the structure is not related to an entity like API responses etc and Entity Identifiers when it's related to the Entities.
Regards,Kshitij
Hi @Thibaut G
As per my knowledge and suggestion, it's best to keep Id attribute as text or long integer in structure. Because in this use case, you don't need to expose your entity as public. So, your entity's access will be fully inside your core module only.
So, I think keeping it as text or long integer will be the best use case.
Regards
Murali
Yeah that makes sense so it also depends on if entity public or not and if structure will be public or not
If you use a <entity> Identifier attribute in structure set to public the entity itself does need to be public.
Hi Murali,
Thank you for your response.
I find myself typically handling the mapping from my structure to my entity within the Business Logic (BL) Module, which consumes the CRUD actions from the CS module. Consequently, I still need to reference my entities in my BL Module.
Am I correct in understanding that with your approach, you eliminate the need to have direct references to your Entities within your BL Module?
Thanks in advance.
Yeah, you're correct @Stefan Weber . Sorry for the deviation.
and yes your understanding is correct @Thibaut G
In terms of comparing with high code, storing it as text is the best practice, because text holds less memory when compared to identifier (Long Integer or integer). Sometimes identifier can be other datatypes also like text or other entity's identifier also.
So storing it as text and use TextToIdentifier while sending it into entity action, api call or required call is best I think.