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!
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
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!
In your aggregate you can right click Id column and select max
You can also sort aggregate by Id desc and get first element in your code for example:
GetEmployees.List[0].SerialNumber
Thank you so much @Mostafa Othman ! Both this suggestion worked great! I appreciate the help!
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.
Hello @Ajit Kurane ,
Thank you for this, this was helpful!
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