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 (Moderator: Donald Lobo) »
  • Creating Incrementing Membership Numbers - On Right Track?
Pages: [1]

Author Topic: Creating Incrementing Membership Numbers - On Right Track?  (Read 3188 times)

chapmanla

  • I post occasionally
  • **
  • Posts: 43
  • Karma: 1
  • CiviCRM version: 4.3.1
  • CMS version: Joomla 2.5.11
  • MySQL version: 5.0.95
  • PHP version: 5.2.5
Creating Incrementing Membership Numbers - On Right Track?
October 06, 2009, 01:49:37 pm
I will be importing a member database that has previously assigned membership numbers.  I plan on mapping these numbers to the External ID Field.  On the front end, I would like existing members to see their membership number and new members to be assigned an incremented value of the last assigned membership number.  I think the only way to do this is to write some PHP code that would look for an empty value in the External ID field and then assign a value that is "+1" to value of the External ID field in the immediately preceding record (I'll make I import the initial records are imported so the the existing membership numbers are in sequence).

Before I try to teach myself how to do this, I am asking any experts out there if there is a better way to accomplish this.

Thanks.

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Creating Incrementing Membership Numbers - On Right Track?
October 07, 2009, 01:52:50 pm
Some things to consider:
* Implement the post_hook to calculate and set the next available External ID when contact records are inserted

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

* You probably should lock the contact table, then get the maximum current value for External ID, then set the next value and save (keeping in mind the External ID has a unique constraint - so if your code tries to set the same value in 2 records you'll get a DB error).
Protect your investment in CiviCRM by  becoming a Member!

BusinessMediaCenter

  • I post occasionally
  • **
  • Posts: 82
  • Karma: 2
  • CiviCRM version: 4.1.x
  • CMS version: Drupal 6 & 7
  • MySQL version: 5
  • PHP version: 5
Re: Creating Incrementing Membership Numbers - On Right Track?
March 31, 2011, 03:44:48 pm
chapmanla

Were you able to get this working?  I need to do the same (create incrementing external id), but am just not good enough with hooks yet to understand how to do this properly


Please advise, thanks!

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Creating Incrementing Membership Numbers - On Right Track?
March 31, 2011, 03:52:15 pm
Does it HAVE to start from the last number in the system. You have an automatically incrementing number for memberships - the membership ID.

The 'traditional' way to do something like this when migrating from one system to another is to pick a number bigger than the largest one in use and then add that to your membership number. E.g your legacy numbers might be 1-1966. You then start your civi numbers at 2000+ membership ID.

Then you don't need to store it & your staff can easily recognise which system it's from
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

BusinessMediaCenter

  • I post occasionally
  • **
  • Posts: 82
  • Karma: 2
  • CiviCRM version: 4.1.x
  • CMS version: Drupal 6 & 7
  • MySQL version: 5
  • PHP version: 5
Re: Creating Incrementing Membership Numbers - On Right Track?
April 06, 2011, 11:47:12 pm
Yep, it has to auto increment the external id from the last available number as we query and use both the external id and civi #s in a legacy application.  Suggestions?

thanks!

adshill

  • I post occasionally
  • **
  • Posts: 96
  • Karma: 8
Re: Creating Incrementing Membership Numbers - On Right Track?
November 21, 2011, 05:33:46 pm
For info, we recently carried this out and I decided to write up the results. Instead of using the external identifier we used the contact ID. You can read the results on the Wiki:

http://wiki.civicrm.org/confluence/display/CRMDOC40/Import+previously+assigned%2C+non-consecutive+membership+numbers+as+Contact+ID%27s

Hope this helps (even if its a bit overdue!)

BusinessMediaCenter

  • I post occasionally
  • **
  • Posts: 82
  • Karma: 2
  • CiviCRM version: 4.1.x
  • CMS version: Drupal 6 & 7
  • MySQL version: 5
  • PHP version: 5
Re: Creating Incrementing Membership Numbers - On Right Track?
December 16, 2011, 01:03:47 pm
Thanks for this, hopefully this will help someone.  FWIW, we wound up altering the legacy app's code

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Creating Incrementing Membership Numbers - On Right Track?

This forum was archived on 2017-11-26.