Author Topic: Swedish Personal identity number (Sweden) Personnummer - Field with validation  (Read 6403 times)

haggan

  • Guest
My question is related to the Swedish personnummer (Personal identity number), that is a important number in sweden. But the question could be more general in the way that I want to create my own data field but it need to have a validation, that validate in my case that the Personnummer is correct.


Offline Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4135
  • Karma: 127
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
If "Swedish personnummer (Personal identity number)"  is unique you can use "external identifier" field (External Id in Contact form).

kurund
Found this reply helpful? Support CiviCRM

haggan

  • Guest
Yes that is possible(it is unique), I also could define a custom number field or date. the Personnummer is on the form YYYYMMDD-XXXX. The problem is that I havent figured out how to create a module/plugin? or something like that not  sure what it is called in civiCRM, that validate the number. I want user to write their Personal identity number when appling for membership and registering on a drupal site.

The algorithm for the validation is easy implemented in PHP but I havent figured out where to put it. aka custom Validation of custom fields. or validation of external identifier.

Offline Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15741
  • Karma: 463
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x

You cannot add a validation rule to a custom field in the current version of CiviCRM. However this is a good idea, and we will potentially add it in a 2.x release. Would be great for you to submit a patch that does the needful, once we roll out the new custom field design

alternatively you can extend the code and add a rule to external_identifier in the xml schema files etc, which then get triggered automtically for profiles. You need to be a competent php5 programmer to do so, and we can assist you on IRC with this

lobo
Reading Give and Take by Adam Grant. If Civi!CRM has helped your org, give back and help others on the forum, contribute code, documentation. Make the project sustainable.

Happy Holidays :)

haggan

  • Guest
I am a bit stuck, Dont really know where to start. I have read all the development blogs. Is there a some sort of guide like drupal module guide for CiviCRM?

Offline Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15741
  • Karma: 463
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x

Can u get on IRC and ping either dlobo or kurund

one of us will be able to help you out.

lobo
Reading Give and Take by Adam Grant. If Civi!CRM has helped your org, give back and help others on the forum, contribute code, documentation. Make the project sustainable.

Happy Holidays :)

haggan

  • Guest
I got another Ideéa Personnr is just an extended date of birth so perhaps thats a better ideéa to extend date of birth with the trailing uniqe numbers. I have been looking in the sql and there is a validation table and a validation_id in the civicrm_custom_field. Is this for use in the future?

I also have notice a strange thing that I think is related to date print out. I have created custom field for a test in my drupal both of Number and Alphanumeric data type and field typ is text.
Then i input a dummy number 190712032456  the numbers is showing up and looking nice every where in civicrm. But I have added them to a profile that shows up in the User account page. But on that page the number is totaly different 2147483647.

I have tested some more and I see a connection with the number lenght.  1907120324 seemse to show up correct but if I ad one digit (19071203241) it shows up as 2147483647.

I have Drupal 5.2 and CiviCRM 1.8.beta.10790

I will try contact you later on IRC
« Last Edit: August 30, 2007, 01:22:09 am by haggan »

Offline Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15741
  • Karma: 463
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x

wim posted an issue regarding this and it is now fixed in 2.0 :)

http://issues.civicrm.org/jira/browse/CRM-2750

lobo
Reading Give and Take by Adam Grant. If Civi!CRM has helped your org, give back and help others on the forum, contribute code, documentation. Make the project sustainable.

Happy Holidays :)

Offline xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4196
  • Karma: 150
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Status of the custom datatype validation rule ?
« Reply #8 on: February 27, 2008, 11:23:35 pm »
Has it already found its way on 2.0 ?

Otherwise, still sound like a nice idea indeed (suggestion: putting a place where we can share custom datatype, eg an IBAN validator)

Offline Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15741
  • Karma: 463
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Reading Give and Take by Adam Grant. If Civi!CRM has helped your org, give back and help others on the forum, contribute code, documentation. Make the project sustainable.

Happy Holidays :)