CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • AutoIncrement Custom Field, Display Value on Form
Pages: [1]

Author Topic: AutoIncrement Custom Field, Display Value on Form  (Read 3827 times)

jacobisreal

  • Guest
AutoIncrement Custom Field, Display Value on Form
March 05, 2010, 05:41:01 am
I have a custom field set up as follows:

Field Label: Volunteer ID
Data Type:  Number
Field Type:   Text

We need to store a unique Volunteer ID for each person that begins with the year and has a 4-digit number, as such: 20101001, 20101002, 20101003 and so on.  The number should auto-increment so that we don't have to look at the last person we added and manually enter the number.  How can we set up the Profile or the Custom Data or a hook so that when a new contact enters this profile information, it gets stored in the database correctly?

Please help... we really need this to work.

Thanks,

Jacob
Project Get Real, Inc.
www.projectgetreal.org - www.pgrnet.net

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: AutoIncrement Custom Field, Display Value on Form
March 05, 2010, 08:07:26 am

1. use a php code custom field

2. implement the hook:

http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+hook+specification#CiviCRMhookspecification-hookcivicrmcustom

and figure out the right value for this contact and update the db table

u'll need to be fairly good at PHP and MySQL to do the above

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

civiuser

  • I’m new here
  • *
  • Posts: 2
  • Karma: 0
  • CiviCRM version: 3.3
  • CMS version: Drupal
  • MySQL version: 5.1.x
  • PHP version: 5.3
Re: AutoIncrement Custom Field, Display Value on Form
March 13, 2012, 02:51:08 pm
Hi, I have a form on my Drupal site for signups. The form gets the contact information and sends it to the client site . I need to count the number of signups. I was wondering If I could create a custom value and increments after each sigup?


xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: AutoIncrement Custom Field, Display Value on Form
March 13, 2012, 02:59:19 pm
Should work same path as lobo highlighted.

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • AutoIncrement Custom Field, Display Value on Form

This forum was archived on 2017-11-26.