xrmverse
Documentation menu

Autonumber columns

← xrmverse documentation

A string column with format Text can carry an AutoNumberFormat (SDK CreateAttribute/UpdateAttribute, the attributes of CreateEntity including the primary name, POST EntityDefinitions(...)/Attributes, solution import and export, and autoNumberFormat in the schema YAML, on a column or on primaryName). Placeholders: {SEQNUM:n} (a sequence, zero padded to at least n digits, that keeps growing past n), {RANDSTRING:n} (n upper-case letters and digits, n from 1 to 6) and {DATETIMEUTC:format} (the UTC time in a .NET date and time format); the rest of the text is copied as is.

  • When values are made. On Create, each autonumber column that the request leaves without a value (absent, null or empty) gets one; a value the caller gives is kept. Update never generates, and rows that exist when a column becomes autonumber are not filled.
  • Checks. As in Dataverse, the placeholders are not checked when the column is created or changed: the Create of a record fails with 400 when the format is not valid (an unknown placeholder, RANDSTRING outside 1..6, SEQNUM below 1, a date format .NET refuses, or more than one SEQNUM, which xrmverse refuses rather than guess). A generated value longer than the column's MaxLength is a 400, never truncated. A format on a column that is not a Text string column is a 400.
  • The sequence. Each column has a SQL Server SEQUENCE ([autonumber].[<column metadata id>]) that starts at 1000. A value taken by a Create that then fails is not given back, so the numbering can have gaps, as in Dataverse. Changing the format keeps the sequence; an empty format removes it; deleting the column or its table drops it.
  • Seed messages. SetAutoNumberSeed (EntityName, AttributeName, Value; prvWriteAttribute; Web API POST SetAutoNumberSeed, 204) restarts the sequence at Value. GetAutoNumberSeed (AutoNumberSeedValue: the last seed set, 1000 by default) and GetNextAutoNumberValue (NextAutoNumberValue) are open to every organization member; Web API GET GetAutoNumberSeed(EntityName='…',AttributeName='…') and GET GetNextAutoNumberValue(…). As in Dataverse, the seed is not part of a solution.

The points that only a real Dataverse can confirm are in docs/superpowers/acceptance/autonumber-checklist.md.