Auto Generate Incident Number

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
nmartin1182
Posts: 8
Joined: 2014-05-30 02:56

Auto Generate Incident Number

Post by nmartin1182 » 2014-10-06 13:13

Greetings Guys,

I am trying to find a way to generate an incident number after submission in the hooks file for records keeping purposes.

The incident number needs to be generated on submission due to the real possibility other users may be submitting records at the same time, it should pick the next available number in sequence.

The sequence can be simple with the first 2 digits being the current year ie: 14-00001 and then next one would be 14-00002, as records are inserted. The record number needs to be read only and MUST NOT update if the record is updated, so it should be after insert in my opinion.

Any ideas are appreciated,

Thanks

udayvatturi
AppGini Super Hero
AppGini Super Hero
Posts: 85
Joined: 2014-06-14 03:08
Location: India
Contact:

Re: Auto Generate Incident Number

Post by udayvatturi » 2014-10-07 04:07

Hi,
There are many ways to achieve this, The best way i recommend it to use after_insert function in hooks.

Get the selectedID after insert
and modify the Selected ID as per your requirement and run a update query.

I am just giving sample code. It may have some errors.

Code: Select all

$num_padded = sprintf("%05s", $data['Selectedid']); // to add 0's infront
$newId="14"+$num_padded ;
sql("update tablename set id=$newId where id={$data['Selectedid']} ",$eo);

Post Reply