Generate Reference entity record codes

Summary

Reference entity record Code Generator overview

The Record Code Generator automates the generation of codes when new reference entity records are created. 

Instead of entering each record code manually, you can configure a generator that builds codes from a structure combining:

  • Free text
  • The code of the reference entity
  • Auto-incrementing numbers

For example, a generator combining the first three characters of the reference entity code, the free textPRD,and an auto-incrementing number can generate codes such as:

  • BRA_PRD_001
  • BRA_PRD_002
  • COL_PRD_001

With the Record Code Generator, you can:

  • Define a consistent structure for record codes.
  • Apply a generator to one or more reference entities, or to all reference entities.
  • Add an auto-incrementing number to generated codes.
  • Apply uppercase or lowercase transformations.
  • Generate codes when records are created through the user interface, imports, or the bulk API.
  • Still provide a code manually when necessary.

The generator applies only to newly created records. It does not modify the codes of existing records.

 

Before you start

Permissions

The Reference entity record Generator permission lives under the Generators section in Settings > Roles. Two levels are available: View lets a user see the list of generators and consult each one's settings, and Manage gives full rights to create, edit, and delete generators, and to edit the nomenclature. By default, users have the View permission; an Administrator can grant Manage or remove access entirely.

 

Create a Reference entity Record Code Generator

  1. Go to Settings > Generators and select the Record Code tab.
  2. Click Create. If you don't see this tab or the Create button, check with your Administrator that you have the appropriate permissions.
  3. In the modal window, fill in a label and a code. The label must not exceed 255 characters. The code must be unique, alphanumeric (underscores allowed), and no longer than 100 characters; it is auto-filled from the label but can be modified manually.
  4. Confirm to open the full editor, organized into three tabs: General Properties, Selection, and Structure.

Once you save a generator, it is active immediately: a code is generated automatically every time a new record is created in the targeted reference entities, as long as no code is provided manually.

One generator per reference entity. Each reference entity can only be covered by a single generator. The Create button is disabled once all reference entities are assigned to a generator.

 

General Properties tab

In the General Properties tab, you can view the generator code (read-only after creation), set the text transformation applied to the generated code, and add label translations for each of your UI locales.

  • No transformation: the code is generated as-is (for example, Print_PRD_0001)
  • Uppercase: the code is fully uppercased (for example, PRINT_PRD_0001)
  • Lowercase: the code is fully lowercased (for example, print_prd_0001)

Selection tab

In the Selection tab, you define which reference entities the generator applies to. Select one or more specific reference entities, or choose All reference entities to apply the generator to every reference entity not already assigned to another generator.

The screenshot above shows the Selection tab, with a reference entity selector that allows choosing one or more specific reference entities.

Define the structure

In the Structure tab, create the template applied when generating a category code. Click Add new property to add one or more properties to the structure, for up to 20 properties. Properties can be reordered by drag and drop.

The screenshot above shows the Structure tab with a list of configured properties (Free text, Auto number, Category tree) and a live preview of the generated code at the top.

Free text

  • Inserts a static text string in the code.
  • Must not be blank and must not exceed 50 characters. Leading or trailing spaces are not accepted.
  • You can add multiple Free text properties.

Auto number

  • Inserts an auto-incrementing number.
  • Minimum digits: sets the minimum length of the number, padding with leading zeros when needed. For example, if set to 4, the number 5 is rendered as 0005. Accepts values between 1 and 15.
  • Minimum number: the starting value for the sequence. For example, if set to 100, the first generated code includes 0100 (assuming 4 minimum digits).

Your structure can contain only one Auto number property.

 

The Auto number always uses the value one higher than the last number ever generated for the same prefix. Deleting a reference entity does not reset the sequence. To fully reset it, delete both the reference entity and the generator, then create a new generator.

 

Reference Entity (root reference entity code)

Inserts a value derived from the root reference entity code of the reference entity being created. Two formats are available:

  • Use the full code: uses the full root reference entity code as-is.
  • Truncate: uses only the first N characters of the root reference entity. Configure the operator (Is equal to (=) or Lower than or equal to (≤)) and the number of characters (between 1 and 5).

Delimiter

By default, no delimiter is added between properties. Tick Use delimiters between each property to activate it. The only accepted delimiter is _ (underscore).

Live preview

A live preview of the generated code is shown at the top of the Structure tab, reflecting your current configuration. It updates automatically as you add, remove, or modify properties, and respects the text transformation set in the General Properties tab.

When is a reference entity record code generated

  • A code is generated only when a new reference entity record is created and no code is provided manually.
  • If a reference entity record already has a code, the generator never overwrites it.
  • Generation is triggered through the Akeneo PIM user interface, an import, or the API.

Existing reference entity records are not updated when a generator is created or modified. Only newly created reference entity records receive an automatically generated code.

 

Edit or delete a reference entity record Code Generator

Modifying or deleting a generator has no impact on codes already generated: all existing reference entity records codes remain unchanged. Only reference entity records created after the change are affected.

  1. Go to Settings > Generators >  record Code.
  2. Click a generator in the list to edit it, or click Delete to remove it.
  3. Confirm the deletion when prompted.