224
Views
8
Comments
Solved
Auto Increment Attribute
Service Studio Version
11.53.27 (Build 61662)

Hello,

I would like to have a auto increment attribute that combines with a string whenever I click a button. For example:

It will go from S-001 to S-002 to S-003 etc... whenever I click the button. I know there is a method to do it with the entity Id where you assign "S-00" + attribute.Id but I would like another approach in doing this. Thank you!

2020-11-25 10-45-32
Mostafa Othman
Champion
Solution

Hello Low,

If this sequence will not reset for example by every month or every year so it easier to use Id value of row and concatenate "S-00"

If you want to calculate it so you can get max record by Id from table and then get value of serial attribute after that you can remove "S-00" and convert string to integer then increment by 1 and finally concatenate "S-00" again

you will need to use for example 

NewSequence = TextToInteger(Replace("S-001","S-00",""))+1

then "S-00"+NewSequence 

UserImage.jpg
Low Nico

Hello @Mostafa Othman ,

Thank you so much for your suggestion! As a followup question, may I ask how to get the max record Id and its attributes from a aggregate/table? Thank you so much!

2020-11-25 10-45-32
Mostafa Othman
Champion

In your aggregate you can right click Id column and select max 

2020-11-25 10-45-32
Mostafa Othman
Champion

You can also sort aggregate by Id desc and get first element in your code for example:

GetEmployees.List[0].SerialNumber


UserImage.jpg
Low Nico

Thank you so much @Mostafa Othman ! Both this suggestion worked great! I appreciate the help!

2025-04-17 05-42-16
Ajit Kurane

Hi Low,

Here I have seen another approach to achieve this one. But in this case they have applied it to the entity attribute not identifier.

https://www.outsystems.com/forums/discussion/73684/auto-increament-value/

Hope it helps you.

Thanks,

Ajit Kurane.

UserImage.jpg
Low Nico

Hello @Ajit Kurane ,

Thank you for this, this was helpful!

2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP

Hi,

The platform does not have that feature built in, do you have to develop it yourself.

Why don't you want to use the logic you mentioned yourself?

Why do you actually need to persist that value? Can you it not just calculate it where needed from the entity Id?

Regards,

Daniel

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