Unable to set Primary key with data type Decimal.

The "Set to Identifier" option seems to have been disabled.

Robert -

Identifiers can be of type integer or text, not decimal.

is it possible to achieve same in Outsystems version 9...
We need to have primary key as decimal datatype....
Hi Salil,

Primary keys are still limited to integers and text.
Why do you need them to be decimal? On entities you are defining or with external tables integration?

João Rosado
salil agrahari wrote:
is it possible to achieve same in Outsystems version 9...
We need to have primary key as decimal datatype....
Hello Salil,

As Justin James and João Rosado said, currently (and this includes OutSystems version 9) Entity IDs (primary keys) can be either integer or text data types.

If you really need to have a PK of decimal type, it is possible to create one of your own. What you need to do is:
- create the entity definition as you would normally
- leave the automatically created ID as it is
- create a new attribute, which is going to play the role of your primary key with decimal type
- set the attribute type to decimal
- change "Is Mandatory" option to "Yes"
- double click the entity, in the entity list, to view the entity details and then:
-- go to the "Indexes" tab
-- create a new index with "Unique" = Yes, and add the attribute that you have just created and is going to play the role of your decimal primary key

and that is it. Now you have an attribute that has all the properties necessary for being used as a primary key. The downside is that you are going to have to write your own logic when creating, referencing and deleting records for that entity, in order to update properly the pseudo-PK attribute. Furthermore, you will have to make sure that you use it (instead of the default ID) when performing joins with other entities. Last but not least, when you want to refer to records of the entity with your "custom" decimal PK attribute, you will need to create "custom" foreign key attributes and manage them manually (as in, foreignKeyAttribute of decimal type whose values need to be micromanaged with your own logic).

Hope this helps you solve your issue.

If you have any further questions, please do not hesitate to place them.

With best regards,


Just adding something to the post from Stoyan...

This doesn't mean that the 'Entity Identifier' data type created is now the decimal field! This will continue to point to the default Id attribute you have on the entity. This may create a lot of confusion on your code!
For example if you want to create relationships between entities it will still use the default Id and not the decimal field. If you use the Entity Identifier data type in your code it will be the default Id attribute and not the decimal one, etc.

Repeating the question from João, why do you need a decimal primary key?
Thanks for reply.

I'll revisit my logic to deal with the scenario... :)

Thanks again

Question - if that decimal type PK is simply mapped to Text in the extension via Integration Studio, will it just change the numeric representation to the String representation?  If so, wouldn't that be the best (and easiest) solution?  (and Mapping to Integer might not work because of the chance of duplicate PKs in the existing data)