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) »
  • General Discussion (please no support requests here!) (Moderator: Michał Mach) »
  • Question: how to toggle relationship status to disable after changing employer.
Pages: [1]

Author Topic: Question: how to toggle relationship status to disable after changing employer.  (Read 382 times)

D3messiah

  • I’m new here
  • *
  • Posts: 2
  • Karma: 0
  • CiviCRM version: 4.4.6
  • CMS version: wordpress 4
  • MySQL version: Ver 14.14 Distrib 5.5.38, for debian-linux-gnu (i686)
  • PHP version: php 5.4
Question: how to toggle relationship status to disable after changing employer.
November 14, 2015, 10:51:40 pm
Hi,
I am new to CiviCRM. What would be the best way to automatically toggle relaship status to disable after current employer changes.?

D3messiah

  • I’m new here
  • *
  • Posts: 2
  • Karma: 0
  • CiviCRM version: 4.4.6
  • CMS version: wordpress 4
  • MySQL version: Ver 14.14 Distrib 5.5.38, for debian-linux-gnu (i686)
  • PHP version: php 5.4
Re: Question: how to toggle relationship status to disable after changing employer.
November 15, 2015, 12:03:26 am
update. I don't know if this the best way to do it. am sure there must be some safer way, what i did is insert this in hook form_postprocess

        $current_employer = CRM_Core_DAO::getFieldValue("CRM_Contact_DAO_Contact",
         $contactid, "employer_id");
         
   $query = "UPDATE civicrm_relationship
   SET is_active=FALSE WHERE contact_id_a={$contactid} AND contact_id_b!={$current_employer}; ";

   $dao = CRM_Core_DAO::executeQuery($query);

jaapjansma

  • I post frequently
  • ***
  • Posts: 247
  • Karma: 9
    • CiviCoop
  • CiviCRM version: 4.4.2
  • CMS version: Drupal 7
  • MySQL version: 5
  • PHP version: 5.4
Re: Question: how to toggle relationship status to disable after changing employer.
November 16, 2015, 12:26:58 am
You should also include the parameter relationship_type_id in your query. The relationship_type_id should refer to the ID of the relationship type Employer
Developer at Edeveloper / CiviCoop

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • General Discussion (please no support requests here!) (Moderator: Michał Mach) »
  • Question: how to toggle relationship status to disable after changing employer.

This forum was archived on 2017-11-26.