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

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

Example of execution

Apply the following rule to the primary key.

Status code + year (two digits of the last century) + month (zero padding) + serial number (zero padding four digits)
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

Example of execution

Apply the following rule to the primary key.

Fixed code ("PJ") + year (four digit AD) + serial number (zero digit six digits)

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
 )
)
  • 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.
  • FISCALYEAR functionReturns the fiscal year.
  • PADDING function, It fills the character string with specified characters and cuts out.
  • SEQ ()A special function that can be used only in the primary key specification partis.It means the number (order) that was automatically numbered.