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 »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • SQL query to set permission on employer/employee relationship
Pages: [1]

Author Topic: SQL query to set permission on employer/employee relationship  (Read 1303 times)

jimmyjam

  • I post occasionally
  • **
  • Posts: 87
  • Karma: 4
SQL query to set permission on employer/employee relationship
June 30, 2010, 03:25:42 pm
Hello,

I have a group of approx 150 individual contacts who are employees of organizations stored in CiviCRM. A relationship has been built between the employees and the employers. However, I need to set the permission that allows employees to manage/modify the employer contact record.

How can I do this with an SQL query?  In a previous forum post, Dave Greenberg mentioned this query:

Code: [Select]
set civicrm_relationship.is_permission_a_b = 1
How do I execute this query for a specific CiviCRM group rather than the whole database? Let's assume the group is called "Employees" and has ID=1.

Thanks,
James 

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: SQL query to set permission on employer/employee relationship
June 30, 2010, 05:21:59 pm
Is membership in the 'Employees' group relevant to what you're trying to do, or simply that these individuals have an employee -> employer relationship with some organization? If you want to filter on a group (group.id = 1)... then something like this should work:

Code: [Select]
UPDATE civicrm_relationship cr
SET cr.is_permission_a_b = 1
WHERE
  cr.relationship_type_id = 4 AND
  cr.contact_id_a IN (
    SELECT contact_id FROM `civicrm_group_contact` WHERE group_id = 1 and status = 'Added');

CAVEAT: Please test this on a test copy of your DB before using it on production DB. Should be right, but no guarantees.
Protect your investment in CiviCRM by  becoming a Member!

jimmyjam

  • I post occasionally
  • **
  • Posts: 87
  • Karma: 4
Re: SQL query to set permission on employer/employee relationship
June 30, 2010, 06:21:31 pm
Awesome, thanks Dave. I appreciate your help.

Have a nice evening.

James

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • SQL query to set permission on employer/employee relationship

This forum was archived on 2017-11-26.