You can also "force" a normal int field to became autonumber as you want to, plus you can obligate it begins with any size and/or add other characters (only in case it is a varchar in database).
Because it is in a new module you can edit default Sugarbean->save() method by inheritance:
PHP Code:
function save($check_notify = FALSE) {
$this->setOrder();
parent::save();
}
function setOrder() {
if ($this->id == ''){
$query = "SELECT order_number FROM my_module_name ORDER BY order_number DESC";
$result = $this->db->query($query,true,"");
$row = $this->db->fetchByAssoc($result);
if($row != ''){
$this->order_number = ($row['order_number'] + 1);
}
}
}
Bookmarks