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) »
  • create relationship between event and contact? is this possible?
Pages: [1]

Author Topic: create relationship between event and contact? is this possible?  (Read 1121 times)

saffrongeek

  • Guest
create relationship between event and contact? is this possible?
October 02, 2009, 02:22:56 am
Hi ,

        As I mentioned, I am taking step by step knowing CRM. I have successfully imported users, events. But I think I missed something while creating relationship.
         My contact table got contact ids from two range due to deletion or table autoincrement set while taking export. It is
         contact ids happens to be 1-120 , and the next contact id starts from 740 to 52000 . Relationships are also fine in user tables. To create relation while importing users I have used the API function.
         Now, I tried to create a relation between event and event manager using same logic. It creates with type id set to event_manager_relationship_type_id but I find it not creating relation for any events whose event id happens to be in the range 120 - 740. This seems some thing reference to contact table. Am I missing sth that I got to build relation between event and event coordinators? OR it is not possible to build relation between event and a contact.

sample Code fragment i used to create user relationship. I just modified the same logic with contact_id_a to be of event_id and relationship_type_id mapped to RoleManger id.

Code: [Select]
                              $params_a = array(
                    'contact_id' => $crm_contact_id,
                    );
                    $params_b = array(
                    'contact_id' => $crm_parent_id,
                    );
                    require_once 'api/v2/Relationship.php';

                    $result = & civicrm_contact_relationship_get( $params_a, $params_b );
    foreach($result as $k=>$entries){
  //foreach($entries as $entry){
    $params_rel = array(
    'id'=> $k
    );
$resultdel = & civicrm_relationship_delete( $params_rel );
    // }
    }
    var_dump($result);
                   
      $params_rel = array(
                    'contact_id_a'             => $crm_contact_id,
                    'contact_id_b'             => $crm_parent_id,
                    'relationship_type_id'     => 1,
              'start_date'               => (isset($date)? $date : $today),//$today,
              //'end_date'               => ,//$today,      
                    'is_active'                => 1
                  );
require_once 'api/v2/Relationship.php';
                $relate = & civicrm_relationship_create( $params_rel );
        if( civicrm_error( $relate)) {
          $errors[$i] = "Error building relationship with : ".$crm_contact_id." to contact : "
            .$res_Set_crm['parent_id']." : ". $relate['error_message'];
        if($cronSettings->browserOn){
    $msg = 'Error: building Relationship ..';
    echo '<p class="good">'.$msg.'</p>';
    }


         

Thanks in advance for the pointer suggestions

Regards

Saffron
« Last Edit: October 02, 2009, 02:24:41 am by saffrongeek »

Yashodha Chaku

  • Forum Godess / God
  • Ask me questions
  • *****
  • Posts: 755
  • Karma: 57
    • CiviCRM
Re: create relationship between event and contact? is this possible?
October 02, 2009, 04:03:10 pm
Saffron :
Quote
Am I missing sth that I got to build relation between event and event coordinators? OR it is not possible to build relation between event and a contact.
In civicrm we relate bunch of contacts with an event as participants which is stored in `civicrm_participant` table and we do NOT store the event -> contact connection in a relationship.

Quote
I just modified the same logic with contact_id_a to be of event_id and relationship_type_id mapped to RoleManger id.
You can only define relationships to store the connection between contacts,
hence contact_id_a had to be a contact.id and NOT any other object.id (in this case event.id)

I would create a new participant role called "Manager",  then import the participants which allows you to INSERT new participant records, or UPDATE existing records, without having to make any changes to the code, etc
You can try out the participant import here :
http://drupal.demo.civicrm.org/civicrm/event/import?reset=1

I would also recommend looking at the Events section of our online book, particularly this chapter :
http://en.flossmanuals.net/CiviCRM/EventReports

HTH
-Yashodha
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

saffrongeek

  • Guest
Re: create relationship between event and contact? is this possible?
October 08, 2009, 01:55:47 am
Hi Yashodha ,

                      Thanks for your patience , consideration, & reply. Your reply helped me understand some basics with relationship and participants.

Regards,

Saffrongeek

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • create relationship between event and contact? is this possible?

This forum was archived on 2017-11-26.