Answers.Body: <p>Thanks @Brad, I created a plugin with <code>appointment_record_id</code> (PK with auto increment), <code>customer_id</code> and <code>timestamp</code> table. I insert a record when system creates Appointment Record, and then I reference the <code>appointment_record_id</code> as my id.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-11T16:08:15.353Z
Answers.LastActivityDate: 2017-08-11T16:08:15.353Z
Answers.UserDisplayName: Angela Chan
Answers.Body: <p>If you were to do this on entry save, it'd be much easier/cleaner.</p>
  
  <p>You'd write a <a href="https://pluginfactory.io" rel="nofollow noreferrer">simple plugin</a> that listened to the <a href="https://craftcms.com/docs/plugins/events-reference#entries-onBeforeSaveEntry" rel="nofollow noreferrer"><code>onBeforeSaveEntry</code></a> event.</p>
  
  <p>The plugin would check the <code>isNewEntry</code> param to make this this is a new entry and not an existing one.</p>
  
  <p>If it's new, you could generate a random numeric value with <a href="http://php.net/mt_rand" rel="nofollow noreferrer">mt_rand</a>, assign it to your custom field and left the request continue so Craft can save it to the entry.</p>
  
  <p>A string field for the unique identifier would be better though, since mt_rand will not always produce unique numbers (for unique numbers you'd need to keep a separate database table and obtain id's within a transaction). If you'd use strings you could use <a href="http://php.net/manual/en/function.uniqid.php" rel="nofollow noreferrer">uniqid('', true)</a> if you deploy on a single server, or better use a <a href="http://codeaid.net/php/generate-a-random-guid" rel="nofollow noreferrer">uuid/guid</a>.</p>
  
  <p>If you didn't do it on save, but wanted to be auto-populated when someone clicked "New Entry", you'd have to do something much more hacky like have <a href="https://github.com/lindseydiloreto/craft-cpjs" rel="nofollow noreferrer">JS loaded</a> load, try to target the field in the particular section with JavaScript and inject the random number into the DOM.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-08T21:45:27.087Z
Answers.LastActivityDate: 2017-08-11T19:30:30.017Z
Answers.LastEditDate: 2017-08-11T19:30:30.017Z
Answers.UserDisplayName: Brad Bell
Body: <p>I created a section for appointment record (channel type). Each appointment record has different fields, i.e. customer name, phone#, address, etc... I would like to set a unique appointment_record_id (Numeric, i.e. 234) for each record.  Is there any way to create it?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-08-08T20:44:56.567Z
Comments.Text: Not 100% sure I'm following... is `appointment_record_id` a custom field?  If so, what type of field is it?  Do you want it to be auto-populated on a new entry or when an entry is saved?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-08-08T21:03:10.813Z
Comments.Text: @BradBell yes, `appointment_record_id` is a custom field. I set that field is `Number`. I want auto-populated on a new entry.
Comments.UserDisplayName: Angela Chan
Tags: <entries><sections><channels><id>
Title: Any ID I could reference in sections
ThreadText: # Any ID I could reference in sections
  
  (Asked by: username_0 on 2017-08-08)
  
  I created a section for appointment record (channel type). Each appointment record has different fields, i.e. customer name, phone#, address, etc... I would like to set a unique appointment\_record\_id (Numeric, i.e. 234) for each record. Is there any way to create it?
  
  **Tags:** entries, sections, channels, id
  
  > **Comments:**
  > **username_1**: Not 100% sure I'm following... is `appointment_record_id` a custom field?  If so, what type of field is it?  Do you want it to be auto-populated on a new entry or when an entry is saved?  
  > **username_0**: @username_1 yes, `appointment_record_id` is a custom field. I set that field is `Number`. I want auto-populated on a new entry.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2017-08-11. Score: 1
  
  Thanks @username_1, I created a plugin with `appointment_record_id` (PK with auto increment), `customer_id` and `timestamp` table. I insert a record when system creates Appointment Record, and then I reference the `appointment_record_id` as my id.
  
  
  ---
  
  ### Answer by username_1 on 2017-08-08. Score: 1
  
  If you were to do this on entry save, it'd be much easier/cleaner.
  
  You'd write a [simple plugin](https://pluginfactory.io) that listened to the [`onBeforeSaveEntry`](https://craftcms.com/docs/plugins/events-reference#entries-onBeforeSaveEntry) event.
  
  The plugin would check the `isNewEntry` param to make this this is a new entry and not an existing one.
  
  If it's new, you could generate a random numeric value with [mt\_rand](http://php.net/mt_rand), assign it to your custom field and left the request continue so Craft can save it to the entry.
  
  A string field for the unique identifier would be better though, since mt\_rand will not always produce unique numbers (for unique numbers you'd need to keep a separate database table and obtain id's within a transaction). If you'd use strings you could use [uniqid('', true)](http://php.net/manual/en/function.uniqid.php) if you deploy on a single server, or better use a [uuid/guid](http://codeaid.net/php/generate-a-random-guid).
  
  If you didn't do it on save, but wanted to be auto-populated when someone clicked "New Entry", you'd have to do something much more hacky like have [JS loaded](https://github.com/lindseydiloreto/craft-cpjs) load, try to target the field in the particular section with JavaScript and inject the random number into the DOM.
  
  
  ---
  
  