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) »
  • Support »
  • Using CiviCRM (Moderator: Dave Greenberg) »
  • Creating a Custom Many-To-One Relationship - UI or Code - Need Help
Pages: [1]

Author Topic: Creating a Custom Many-To-One Relationship - UI or Code - Need Help  (Read 755 times)

paulakg4

  • I’m new here
  • *
  • Posts: 2
  • Karma: 0
  • CiviCRM version: 4.1.1
  • CMS version: Drupal 7
  • MySQL version: MySQL version 5.5.16
  • PHP version: PHP Version 5.3.10
Creating a Custom Many-To-One Relationship - UI or Code - Need Help
March 10, 2012, 10:58:45 pm
Hi guys,
 
Straight to the point:

 I work with a child sponsorship organization. The core of our model is a Many-To-One relationship in which each child in our organization can have one and only one sponsor at any given time. However we also keep a 'sponsorship history' which includes previous sponsors that may have 'dropped' the child for various reasons.... basically exactly the same as the Current Employer/Employee model (a person can also sponsor more than one child)       ... a textbook many-to-one relationship.

Initially I was under the impression that relationships could be connected through the referenced contact custom field type. However there seems to be a difference (thats not clearly defined) between 'Referenced Contacts' and 'Related Contacts'.

SO-  I see that I can create custom relationship definitions.. but I cant seem to restrict them to anything less than a Many to Many relationship... like the Employer/Employee relationship seems to be.

If there is something Ive missed in the GUI please let me know. Ive read through quite a few posts but they dont really seem to address the core relational issue Im dealing with. The only place I ran across something similar was in the 4.1.2 schedule..

Im not a programmer but I can be when I have to.. If there is a way to currently do this in GUI that Im missing please advise.
Else if you can point me in the right direction for related post OR recommend where in the code it would be good to start customizing I would greatly appreciate any help.



xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Creating a Custom Many-To-One Relationship - UI or Code - Need Help
March 11, 2012, 01:08:27 am
Hi,

Why aren't you using the "normal" relationship tab? You could create a new type of relationship "sponsor" and you can have several relationships at the same time, and keep an history of the previous ones when they stop.

I'd suggest to create a contact subtype "child" and restrict the relationship between a contact & a child, to avoid mistakes.

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

paulakg4

  • I’m new here
  • *
  • Posts: 2
  • Karma: 0
  • CiviCRM version: 4.1.1
  • CMS version: Drupal 7
  • MySQL version: MySQL version 5.5.16
  • PHP version: PHP Version 5.3.10
Re: Creating a Custom Many-To-One Relationship - UI or Code - Need Help
March 11, 2012, 12:42:44 pm
Thanks for the reply X

I tried doing just that the first time- created two contact subtypes Child and Person, and created a relationship Sponsored by/Sponsors.

Maybe Im missing something but I wasnt able to figure out how to restrict the relationship to where a child can have only one sponsor at a given time.

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: Creating a Custom Many-To-One Relationship - UI or Code - Need Help
March 11, 2012, 03:59:22 pm

You will need to implement the restrictyion via hooks, specifically the validate hook. U'll need to have some experience with php and the civicrm api

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

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM (Moderator: Dave Greenberg) »
  • Creating a Custom Many-To-One Relationship - UI or Code - Need Help

This forum was archived on 2017-11-26.