Generate new number (+1) on duplicate record

Generate new number (+1) on duplicate record

Hi,

I have a form and when a record is created for that client it checks how many records exist and adds 1 to give a new report number as below:

  1. if(group_client != null)
  2. {
  3. ClientNo = client[ID == input.group_client].client_id;
  4. Counter = group[group_client.client_id == ClientNo].count() + 1;
  5. input.group_report_no = Counter;
  6. }
It works a treat, however, when you duplicate the record the script obviously doesn't run and it just takes the number from the cloned record.

I thought perhaps triggering on duplicate, however, not supported from what I read

Does anyone have a solution to help, please

Regards