CMDBuild Forum

How to get a sequence number as part of the code attribute as auto value

How can I get a sequence number or the actual number of records of a card to set this value as an auto value in Code attribute ?

The idea behind this question was to generate a more or less unique value for the Code Attribute per class.
Instead of getting a sequencenumber from Database a maybe better solution is to generate the number based on the current timestamp.

My solution in Auto Value:
var code = api.getValue(“Code”);
if (code == null) {
var dt = new Date();
api.setValue(‘CAB-’ + Ext.Date.format(dt, ‘U’));