111
Views
10
Comments
Solved
Best Practice regarding Structure Id attributes
Application Type
Reactive

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 

2021-10-09 07-57-44
Stefan Weber
 
MVP
Solution

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.

2025-12-15 09-29-24
Thibaut G

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. 

Regards

Thibaut 


2025-12-15 09-29-24
Thibaut G

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 

2021-10-09 07-57-44
Stefan Weber
 
MVP
Solution

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.

2025-12-15 09-29-24
Thibaut G

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. 

Regards

Thibaut 


2023-02-26 23-17-33
Kshitij Raheja

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

2024-05-02 09-49-04
Murali Manoharan V
Champion

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

2023-02-26 23-17-33
Kshitij Raheja

Yeah that makes sense so it also depends on if entity public or not and if structure will be public or not 

2021-10-09 07-57-44
Stefan Weber
 
MVP

If you use a <entity> Identifier attribute in structure set to public the entity itself does need to be public.

2025-12-15 09-29-24
Thibaut G

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.

2024-05-02 09-49-04
Murali Manoharan V
Champion


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.


Regards

Murali

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.