Answer
Consider using the platform's existing Number Counter mechanism (under Document Basic) instead of building your own — define a counter with its own ID values (letting you scope separate counters per project, drawing type, or similar), a starting value, a fixed display length (with automatic zero-padding), and an optional prefix/suffix, and reference that counter to generate the next number rather than writing custom sequence-tracking logic in a custom field or stored procedure from scratch.