AutoIncrement Field on Entity - After save it set the field as null

I was trying to …

Make Field on Entity as AutoIncrement to automatically generate it’s codes.

obrazek

I was expecting …

  1. When I edit the entity in html5 client I expect the new number get generated.
  2. When I save the entry, the value will be saved including autonumber field

Instead I’ve got …

  1. Field value is generated correctly in sequence (Before save)
    obrazek
  2. When I save the entry, the value is set to null (After save)
    obrazek

Notes

  • There is no rule on the screen
  • There is no State workflow for the entity
    (at least as far as I know :slight_smile: )

Environment

  • html5
  • master-latest

Auto increment field works only if AllowNulls is set to False. Then it should use the database’s numbers after saving. So the number you see might not be the final number, it may change after saving (e.g. if somebody else picked up your number).

Generally I would not recommend to use this as using numbers for unique identifiers brings terrible problems (e.g. not knowing the final number until you save).

For generating user sequences we have a GenerateSerial (sequenceCode) - ORIGAM Documentation - ORIGAM Documentation XSLT function that you would use typically in a state event (on saving).
What is your use case?

Hi Tomas,

thank you for the explanation of the idea behind this feature. So then it is not a bug.

My use case is to generate unique identifiers (numbers) for service operations. We have a list of service operations and each operation has its code. It is a sequence of numbers. Now, the numbers has certain “inner logic” which is not needed anymore. So the idea is to generate unique number for any new service operation inserted into the list.

So I won’t use this feature and I will use GenerateSerial function, probably in the State workflow whenever new record is created.

Thank you,

David

1 Like