setting an attribute with date data type as identifier

setting an attribute with date data type as identifier

  

I want to set an attribute with date data type as identifier but the option is not showing. Please help me resolve this issue.

Hi Amanda,

You will need to provide a bit more details than you did. What "option" isn't showing? Where do you expect it to show? What did you already try?

In general, when you add an Attribute to a Structure or Entity, there's three ways to set the Data Type:

  1. Service Studio does it automatically. If the name has "Date" in it, SS will make it a Date type, if it detects an Entity name with "Id" at the end it will make it an Identifier for that Entity, etc.
  2. You can select a Data Type from the Data Type property drop down list. This may become unwieldly if you have a lot of Entities.
  3. You can, in the Data Type property input, type the first letter of the data type; repeatedly for the 2nd, 3rd instance etc.

If you cannot find the right data type, then probably it is not referenced. Did you check the references? Does the Entity you want an identifier of appear on the Data tab?

Hi Kilian Hekhuis,

You misunderstood my question.

I have already have an attribute of  the datatype "date"

If I right click that attribute and try to "set it as identifier", I am not able to do it. As you can see in the image below, "set as Identifier" is not accessible. Why? Can't an attribute of data type "date" be set an identifier?

Hi Amanda Soyza,

Primary Key is a simple unsigned integer because there are many cases where there is no perfect candidate for Primary Key. The auto increment allows this column to be automatically filled by the database (and be unique) during inserts 

if you want to create a date as the identifier it will serve as the primary for the table and you cannot add two same dates in the table are you sure about the flow.

Hi Amanda,

Only Integer, Long Integer, Text  and other Identifiers can be set as Identifier. But in general you wouldn't want to set any other attribute than the default AutoNumber Id as identifier, unless you have a foreign key that's also the Id (typically used for extension tables).

As Kirit already said, setting a date field to an identifier doesn't make sense. Why would you want to do that?

Solution

Amanda Soyza wrote:

Hi Kilian Hekhuis,

You misunderstood my question.

I have already have an attribute of  the datatype "date"

If I right click that attribute and try to "set it as identifier", I am not able to do it. As you can see in the image below, "set as Identifier" is not accessible. Why? Can't an attribute of data type "date" be set an identifier?

Amanda,

why do you want a date field to be Identifier? 

Why not keep the Id as Identifier and create an Index to have unique dates on that date field?


Abílio Matos


Solution

Hi Amanda,

Date columns cannot be set as Identifier. Can you explain the instance why you need to use it as Identifier? I am trying to understand your situation so our friends here can help your situation.

Regards,

Edwin

Hi everyone,

I am also having some trouble with setting up an entity identifier data type for the attribute GenreId. OutSystem seems to have constrained a few types of identifiers and unable to autogenerate 'Genre Identifier' data type. Please find attached a screenshot of the properties for the attribute GenreId. 

I was under the impression that OutSystem could generate data types automatically, given a new concept for example GenreId or NameId to Genre Identifier or Name Identifier, respectively. Correct me if I am wrong to assume this.



PS: I succeeded on first attempt to create a Movie Genre Identifier data type, but now unable to do so. 


Best

Ben

Hi Ben,

First a tip: it's easier to get an answer to your questions if you open a new topic. This topic is already markerd as answered, which means not many people will take a look at it. Also, your questions doesn't seem directly related to the original question, and the original question is already a few months old.

Now your question. You're right in assuming that Service Studio tries to guess the data type of a new Attribute based on the name. If you have an Entity named Xxx, creating an Attribute called XxxId will automatically set it to type Xxx Identifier. Sometimes Service Studio guesses wrong, and there are some known bugs in the guessing, and in those cases you can select the right type manually.

If you don't see the right Identifier in the list of possible Identifiers, as in your example above, that means that you haven't referenced that Entity. So hit the "Manage Dependencies..." button (), select the eSpace the Entity is defined in, and select the Entity.

Kilian Hekhuis wrote:

Hi Ben,

First a tip: it's easier to get an answer to your questions if you open a new topic. This topic is already markerd as answered, which means not many people will take a look at it. Also, your questions doesn't seem directly related to the original question, and the original question is already a few months old.

Now your question. You're right in assuming that Service Studio tries to guess the data type of a new Attribute based on the name. If you have an Entity named Xxx, creating an Attribute called XxxId will automatically set it to type Xxx Identifier. Sometimes Service Studio guesses wrong, and there are some known bugs in the guessing, and in those cases you can select the right type manually.

If you don't see the right Identifier in the list of possible Identifiers, as in your example above, that means that you haven't referenced that Entity. So hit the "Manage Dependencies..." button (), select the eSpace the Entity is defined in, and select the Entity.

Hi Killian,


Your comment was very helpful. 

As you may have guessed, I am a newbie here. So, thanks for the tips on using the forum.

Looking forward to posting more questions in my journey to master the OutSystem development environment.

Kind regards

Ben