Support > Repository > Primary key option > Set an arbitrary format (user-defined pattern)

I will explain how to set arbitrary format by using the function provided by Wagby.

An example

Apply the following rule to the primary key.

ステータスコード + 年(西暦下二桁)+ 月(ゼロ詰め)+ 連番(ゼロ詰め四桁)
Figure 1 New customer's report, primary key is "114041000"

Definition method

Figure 2 shows the overall configuration of the "report" model.

Figure 2 Report model

The primary key item "ID" isString typeAnd we will use the order. Set the user definition as follows.

Figure 3 Advanced setting of primary key
CONCATENATE(
  TOSTR(${status#id}),
  RIGHT(
    PADDING("0",2,YEAR(TODAY())),
    2),
  RIGHT(
    PADDING("0",2,MONTH(TODAY())),
    2),
  SEQ()
)
  • By writing $ {status # id}, ID value of the status item can be obtained.
  • CONCATENATE functionConcatenates multiple character strings specified by comma separators.
  • Since all arguments to the CONCATENATE function are character strings,TOSTR functionWe are changing the number to a string with.
  • RIGHT functionFetches N digits from the right of the string.
  • PADDING function, It fills the character string with specified characters and cuts out.
  • YEAR functionRetrieves the "year" part from the date type value.
  • MONTH functionFetches the "month" part from the date type value.
  • TODAY functionReturns today's date.
  • SEQ ()A special function that can be used only in the primary key specification partis.It means the number (order) that was automatically numbered.
SEQ () can not be used with automatic calculation formulas or initial values.

- Indicates the initial value of "status" model (status_m)."New" assign code 1, "existing" assign code 2 respectively.

Figure 4 Initial value of the status model

An example

Apply the following rule to the primary key.

固定コード("PJ")+ 年度(西暦四桁)+ 連番(ゼロ詰め六桁)

The primary key item "ID" isString typeAnd we will use the order. Set the user definition as follows.

Figure 4 Advanced setting of primary key
CONCATENATE("PJ",
 TOSTR(FISCALYEAR(TODAY())),
 RIGHT(
   PADDING("0",6,SEQ()),
   6
 )
)