In which table are the automatic numbers stored? I need to reset them once a year. I mean to fields defined as "Autonumber"

Hi,

 

Does anyone know what table they are in, I need to reset them once a year.

 

We, when a record is generated with Autonumber, we add to the Autonumber field, the year. So we need each year to have a new numbering, starting with 1.

 

Thanks in advance

 

Julio Falcón

Like 2

Like

10 comments

Hi Julio

The AutoNumber value is stored in a Sequence in the database (Postgres Sequence for cloud instances).
For example, you can get the last value of a sequence using this query:
SELECT last_value FROM "Contact_RId_seq".

To reset a sequence, you can use the following query:
ALTER SEQUENCE "seq_name"
RESTART WITH 0;

Hope this helps!

Mohamed Ouederni,

Thanks,

 

1.- But, can I access this data from a process? 

2.- Have access to this object from a process, 

3.- How to determine which sequence correspond with a specific section?

I have not visible this table from a Creatio Cloud instance, I've enabled an autonumber field in contacts, for example, and not available the table mentioned by @Mohamed, see it

 

Hi Julio

 

1- You can run a custom SQL query from a Task Script.
2- No, you don't have access to the sequences.
3- The sequence name is identical to the column UId. You find it in the source code tab of the Object in Advanced settings.

 

Thanks!

Hello Julio,

Once you add the autonumber column, you'll need to get the UId for the column. You can open the object then select "Open metadata" under the Actions menu, the find the column and get the Guid for the UId. 

That is the name of the sequence in the database. If needed, you can use that to get the next sequence value using this where the guid is the UId for the column (for Postgresql):

SELECT nextval('ed398640-de69-842b-c50c-6c673da5aa98')

Then to reset it to 1 again you can use this (if needed, replace the 1 with whatever number you want the sequence to start at): 

SELECT setval('ed398640-de69-842b-c50c-6c673da5aa98', 1, false);

To do this via a process, you'll need to do a direct database connection and you'll use a script task, see https://customerfx.com/article/executing-direct-sql-statements-in-a-process-or-configuration-web-service-in-creatio-formerly-bpmonline/

Lastly, if you want to get what the last value/number used from the sequence was, you can use:

SELECT last_value FROM "ed398640-de69-842b-c50c-6c673da5aa98"

Ryan

This is No Code ? In Classic UI was sImple, why in Freedom I need NASA certification to do this?

Julio.Falcon_Nodos,

Yes, for now to reset the value it requires the database update (either by Clio, SQL Executor, or asking support to update the value). I do hope we'll get a UI to manage that at some point. The prefix is also set at the object level now, instead of a system setting - so that now requires an object publish to change rather than updating a setting.

Ryan

Ryan Farley,

Thanks for your support Ryan

Julio.Falcon_Nodos,

Hello,

Yes, unfortunately at this moment there is no possibility to reset sequence using No Code. But you can always contact support, and we will be happy to do it for you. We have created a request to the responsible development team to add this functionality in future releases.  

Antonii Viazovskyi,

Thanks Antonii

Show all comments