Hello Community,

How to write the auto-numbering of field using Stored procedure SQL


Thanks In Advance


Like 0





Please note that autonumbering became available starting from Creatio version 8.0.5, you can find more info in this Creatio article and this:


It is now possible to number new records in Freedom UI automatically quicker and easier using the [ Autonumber ] field. You can set the number prefix and change the quantity of digits in the number. Creatio populates the field both when you add a record manually and when a business process or integration add it.


Mira Dmitruk,

Yes but i need this for the 8.0.0 version



In such case this article should provide the needed instructions.

Mira Dmitruk,

Thanks but the requirement is with stored procedure 

Mira Dmitruk,

Hello, We have a cloud instance where we need to run auto increment based after insertion. Do we have any examples ?

Show all comments


We have an option to set the field value automatically in an incremental order when a record is created/added to the section.


Creatio Academy Article:
Here, is the link to Set up auto numbering for the [ Code ] field in the [ Products ] section

For any Custom Section, Kindly follow the below guidelines while creating system setting:

Server-Side Implementation:
Let us consider the custom section object is "Transaction" and the system setting - Prefix for object name is "Usr" and the field called Transaction Number(UsrTransactionNumber) has to be auto-numbered.


For the Custom object, Replacing object is not required as you have control over your object, click on the object and check the "Before Record Added" checkbox.

The name of the System setting created for auto numbering should be as below,

1.UsrTransactionCodeMask (Prefix + Object name + "CodeMask")

2.UsrTransactionLastNumber (Prefix + Object name + "LastNumber")


-->In the Condition flow, use your Custom field name instead of code as below, 


-->In the business process, script task use your custom field name instead of Code as below, 
Entity.SetColumnValue("UsrTransactionNumber", UserTask1.ResultCode);


-->Name the script task elements as ScriptTask1, ScriptTask2 & user task element  as UserTask1 as mentioned in the article.


a)Transaction Code Mask

b)Transaction Last Number



Best Regards,

Bhoobalan Palanivelu.

Like 0





This solution is not working for me in case of a custom section object. I have used the exact same steps as mentioned by you in this article and in the Creatio Academy. I tried this in Creatio 7.18v.



The link to the documentation is dead. Here is the new link : https://academy.creatio.com/docs/node/2311

Show all comments

hi all,

I'm doing the server side auto numbering shown in this link on a created package and a created section 

- my section is called returns 

- my field that i want to make auto number is Code 



 followed all the steps shown in screenshots and doesn't work ? 

and here from the object file i opened the process and made this 

 with these configurations


conditional flow: 

conditional flow formula:

Get entity schema to generate number:

Generate number and error icon :

Save number to entity column:


any sol please 

thanks all 

Like 0



Hello Ibrahim,

What is the name of the column in your returns object where the number will be stored? In the article on the academy website, it's using a column named "Code", but your column name is likely different, possibly something with a prefix in front of it, like maybe UsrCode?

You'll need to update the column name in two places:

  1. The conditional flow formula (replace "Code" with your column name)
  2. Save number to entity column (replace "Code" with your column name)

Also, it would be a good idea to verify the names of the process elements. The academy article assumes they are named "UserTask1", etc.   Verify the following:

  1. The task titled "Generate ordinal number", verify it's name by clicking the three-dots icon on the top of it's properties, then select "Advanced mode" and there you'll find it's name in the "Code" field. You'll need to update the code in your screenshot titled "Get entity schema to generate number" with this name - replace "UserTask1" with this value, if different.
  2. Do the same with the "UserTask1" value in the code in your screenshot titled "Save number to entity column", if different.

Lastly, if it is still not working, please post the error you receive when you publish.


Dear Ryan,


Thank you for your answer, it is very helpful. Additionally to doing everything from the message above you have to put the whole process In the "Event sub-process element".


Ryan Farley,

Thank you for your answer 


yeeees that's it 

thank you 

Hi Ibrahim,


Could you please help me with what I am missing with the same implementation? I have created the post on it https://community.creatio.com/questions/event-trigger-issue


Thank you

How to do Auto-numbering using SQL Script using Stored procedure

Show all comments

Hi all,

as this link 



i need to make auto numbering in custom section called returns 



i made the first point "1. CREATE TWO SYSTEM SETTINGS" and created the two system settings 

in the second point " CREATE A REPLACING SCHEMA OF THE [PRODUCT] OBJECT" when i create and choose the returns section as parent object it gives me an error like that :


how can i solve this ?



Like 0



Dear Ibrahim,


Thank you for your question!


As per the Article provided: 

Select a custom package and execute the [Add] – [Replacing object] menu command on the [Schemas] tab. Specify the [Product] object as the parent object in the new object properties


Please check if you are creating a replacing object within the Custom Package 


Thank you!

Hope this helps,



Danyil Onoprienko,


yes within the custom package 



Ibrahim Nour Eldin,


Thank you for your answer!


Please make sure that you specify the [Product] object as Parent when creating a replacing object


Thank you!



Danyil Onoprienko,


thanks for your reply

i guess you doesn't read my question but i will explain to you 

i need to make auto number on a custom section not on products and my custom section is called returns 



Ibrahim Nour Eldin,


The Article provided is a guide on how to add auto-numbering to the [Products] section.


Since you have already created a custom section named [Returns] that is based in the Custom package (all new custom objects are being created and stored in the Custom package) you receive the following error as there would be two similar objects referring one to each other.


You may continue to step 3 if you are using a custom section named [Returns]


Step 2 is considered for those objects that aren't located in the Custom package initially (for example, you have developed a new package and imported it in a new system having the [Returns] section in that package - for these purposes, you would need to create a "Replacing Object" in a Custom Package on a new instance to which this package has been installed)

Hope this clarifies!



Danyil Onoprienko,


when i skip 2 and go to advanced setting to enable event handler i found two files with the same name for the Returns section on in the Custom Package and one in the Package i created 

where should i enable the event handler ? 


Ibrahim Nour Eldin,


Thank you for your question


You may read on how to use the Object Designer to configure entity schemas here: https://academy.creatio.com/documents/technic-sdk/7-15/workspace-object…


Hope this helps!


Thank you


Danyil Onoprienko,


you don't understand me in my last question i asked about where i enable event in the section file in my package or in the section file in the custom package 



Ibrahim Nour Eldin,


Thank you for specifying!


The Event Handler should be enabled in the Custom Package




Danyil Onoprienko,


when i build the business process in formula when i write the code it gives me this error 


Danyil Onoprienko,


any sol please for this ?



Ibrahim Nour Eldin,


Please contact us at support@creatio.com in order for us to provide the best possible solution


Thank you!



Show all comments

Good day.

I am new to BPM Online(And C#). I just registered a 14 day free account to try it out.

I want to use the sub process to create a case number when a new record is created on a section. Please see the image below:

When the new record is saved the process starts and reads the zone filed from the request record as depicted below:

Upon reading the zone field I then assign the zone filed to the zone process variable using the formular task as depicted below:

I then use the zone process variable to formulate the case number in the code script as depicted below:

string unique_numer =  DateTime.Now.ToString("yyMMddhhmmss");
string  zone_val = Get&lt;Guid&gt;("zone").ToString();
string case_number=(zone_val+"-"+unique_numer)
return true;

The challenge I am facing is to get the value of the selected lookup zone field to store the value into zone_val string filed.

How to get the selected value from the zone lookup filed using C# code. The value that I get is a Guid data type and cannot get the value of the lookup.

I need to store the generated CaseNumber to the case_number field in the database as depicted below:

You help will be highly appreciated as I am currently stuck.


Like 0



Dear Tebogo,

You may create a system setting that will store this number and use it in the future number generation. You can find detailed example here: https://academy.bpmonline.com/documents/technic-sdk/7-13/how-add-auto-n…

Best regards,

Assuming you want the field name in the Zone Table : 

var uc = Get&lt;UserConnection&gt;("UserConnection");
Guid zoneId = Get&lt;Guid&gt;("zone");
var esq = new EntitySchemaQuery(uc.EntitySchemaManager.GetInstanceByName("Zone"));
var entity = esq.GetEntity(uc, zoneId );
string zoneName = entity.GetTypedColumnValue&lt;string&gt;("Name");


Angela Reyes,

Thank you very much Angela.

Jerome BERGES,

Thank you very much Jerome, highly appreciate it!

Show all comments

I am trying to add an auto-numbering field on Opportunity.


I successfully did this with the Product object just like the guide said. It was very easy.

But when I try to do the same thing on Opportunity, there are some differences. Opportunity does not have the inherited Code –property or the methods called in the code under onEntityInitialized()

I have only tried the client-side solution.

Best regards,

Like 0



Hi, Julius!

As you have your own field in Opportunity (e.g. "UsrCode"), so you can use:

    onEntityInitialized: function() {
                 // onEntityInitialized method parent realization is called.
                // The code is generated only in case we create a new element or a copy of the existing element.
                if (this.isAddMode() || this.isCopyMode()) {
                    //  Call of the Terrasoft.BasePageV2.getIncrementCode base method, that generates the number 
                    // according to the previously set mask. 
                    this.getIncrementCode(function(response) {
                    // The generated number is stored in [Code] column.
                        this.set("UsrCode", response);

Dear Julius,

Since opportunity section does not have an existing Code column, you can create one using means of section wizard.

No special methods needed for new column, since we are calling parent realization in the onEntityinitialized method, which has the logic of working with auto incrementing. Just be sure to indicate your custom column in the this.set method by its name, but not title.

As for the back end realization of the auto incrementing, follow the instructions just the same, but indicate name of the custom column.




Anastasia Botezat, Vladimir Sokolov,
I tried this again. But it's not working. No value gets set.

I have created the System Settings, the Property on Opportunity, And I have adjusted the JavaScript to have the correct string value, "UsrCode".

It's not working this time either. Is the on-client method unavaliable on the Opportunity object?

Maybe the Opportunity object does not know the Systems Settings i Created. The system settings code names are : OpportunityLastNumber and OpportunityCodeMask

UPDATE : It is working while using Copy. But no Code is set when adding an Opportunity with the Mini-Page. I am now working on this. Any advice appreciated.

UPDATE 2 : Creating and Copying works as long as I do not have a Mini-Page. I tried to add the same JavaScript in the MiniPage methods{}. But that's not working. Any tricks to use MiniPages?


The auto increment logic is not a part of basic mini page logic. The 

getIncrementCode method is written on the BasePageV2. However, mini pages are inherited from BaseMiniPage, which does not have such method.

You can add the getIncrementCode method realization to the mini page, so that it will execute the logic. 

As for the back-end part, the changes are displayed on the client side only after record is saved. Therefore, it is impossible to view the code value on the opportunity page immediately. 



Anastasia Botezat,

 I did not get this to work with Mini-Page. I have anyway decided to work without the mini-pages. When Creating a Opportunity I just get the regular edit page where the incremented numbers work fine. Thank you.

Anastasia Botezat,


This dint worked  even to me. 


I have posted the issue in detail in the above link. Please help!!!!



Show all comments