Auto-number sequence generation not working in Creatio Online environment

Hello,

We are importing data from an external ERP system and creating records (e.g., Orders / Invoices) via backend code. These objects have an auto-number column (“Number”) configured with a prefix such as ORD- or INV-.

We attempted to generate the next auto-number value by querying the database sequence directly using SQL like NEXT VALUE FOR based on the column UID. This approach works in some local environments but fails in Creatio Online. The query either throws an error or does not return the expected value.

Below is the code we have written for next sequence:
 EntitySchema entitySchema = userConnection.EntitySchemaManager.GetInstanceByName(objectName);
                    var numberColumn = entitySchema.Columns.GetByName("Number");
                    string sequenceName = numberColumn.UId.ToString();
                    
                    long nextValue=0;

                    try
                    {
                        string sql = $"SELECT NEXT VALUE FOR dbo.[{sequenceName}]";
                        
                        using (var dbExecutor = userConnection.EnsureDBConnection())
                        {
                            using (var reader = new CustomQuery(userConnection, sql).ExecuteReader(dbExecutor))
                            {
                                if (reader.Read())
                                {
                                    nextValue = reader.GetInt64(0);        
                                }
                            }
                        }
                    }
                    catch(Exception ex)
                    {
                        
                    }

The trail online version of Creatio is "8.3.2.4199". 

What are we missing here?

Any help would be appreciated.

Like 0

Like

0 comments
Show all comments