How is your experience with the OutSystems Community?
16
Views
4
Comments
Solved
Auto-Generate Unique Employee Code in Out Systems Without Using SQL
Application Type
Reactive


Hi,

 I need help with implementing auto-generated Employee Codes in OutSystems.

I have an Employee entity, and whenever a new employee record is created, I want the system to automatically generate a unique Employee Code in the following format:

  • SA-101
  • SA-102
  • SA-103
  • and so on...

Here:

  • SA- is a fixed prefix for every employee.
  • The numeric part should increment automatically for each new record.

I want this code to be generated automatically during the Create action of the Employee entity.

Also, I would like to use OutSystems built-in functions (such as Generate Password or similar built-in logic/functions) instead of writing custom SQL queries, if possible.

Could someone please explain:

  1. How can I implement this auto-increment Employee Code generation in OutSystems?
  2. How can I ensure the generated code is unique?
  3. Can this be done without using SQL?
  4. What would be the best practice approach for this scenario?

I will attach the entity structure screenshot for reference.

2023-09-06 07-26-35
Sudip Pal
Solution

Hi @ATUL TIWARI ,

To generate the EmployeeCode you need to follow the below steps.

  1. Make sure your EmployeeCode has the Unique Property set to YES.
  2. Unique EmployeeCode Creation Logic
    • Create a server action which will generate the Unique EmployeeCode 
    • GetLatestEmployee.List = Fetch the last record of the Employee [ Employee.CreatedOn DESC and Max record set to 1]
    • If GetLatestEmployee.List.Empty is True, then Generate EmployeeCode is SA-101, otherwise extract the numeric from last employee code and increment by 1.At last add prefix SA to that numeric value.

I hope this will help you. Let me know if you need any OML for that.

Thanks,

Sudip

2026-07-23 15-58-00
ATUL TIWARI

i was trying in your way .. if you have  the oml then please  send me ..


2023-09-06 07-26-35
Sudip Pal
Solution

Hey @ATUL TIWARI ,

Check the OML below. If you need any help let me know.

Thanks,

Sudip

EmployeeCode.oml
2026-07-23 15-58-00
ATUL TIWARI

ok, it is working fine, Thank you.

2023-09-06 07-26-35
Sudip Pal
Solution

Hi @ATUL TIWARI ,

To generate the EmployeeCode you need to follow the below steps.

  1. Make sure your EmployeeCode has the Unique Property set to YES.
  2. Unique EmployeeCode Creation Logic
    • Create a server action which will generate the Unique EmployeeCode 
    • GetLatestEmployee.List = Fetch the last record of the Employee [ Employee.CreatedOn DESC and Max record set to 1]
    • If GetLatestEmployee.List.Empty is True, then Generate EmployeeCode is SA-101, otherwise extract the numeric from last employee code and increment by 1.At last add prefix SA to that numeric value.

I hope this will help you. Let me know if you need any OML for that.

Thanks,

Sudip

2026-07-23 15-58-00
ATUL TIWARI

i was trying in your way .. if you have  the oml then please  send me ..


2023-09-06 07-26-35
Sudip Pal
Solution

Hey @ATUL TIWARI ,

Check the OML below. If you need any help let me know.

Thanks,

Sudip

EmployeeCode.oml
2026-07-23 15-58-00
ATUL TIWARI

ok, it is working fine, Thank you.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.