mecachisenros/cf-civicrm

Invalid Relationship when adding 2 contacts where one is an organization

Opened this issue · 4 comments

Describe the bug
When submitting a form I get "Invalid Relationship"

To Reproduce
Steps to reproduce the behavior:

  1. Processor Contact 1: An individual (the one logging in to use the form)
  2. Processor Contact 2: Linked to an Organization
  3. Processor Relationship Contact 1 / Contact 2 where it is set as [Individual]Employee of - [Organization]Employer of
  4. Processor CiviCRM Address: Contact 2 linked to, Type Main
  5. Processor CiviCRM Address: Contact 2 linked to, Type Home

I made sure that the current logged in user has permission to view/modify the organization

Expected behavior
I assumed that setting this relationship would allow me to update hte address of the organization, but I cannot.

Screenshots
#0 /example.org/wp-content/plugins/cf-civicrm/processors/relationship/class-relationship-processor.php(90): civicrm_api3('Relationship', 'create', Array) #1 /example.org/wp-content/plugins/caldera-forms/classes/core.php(3283): CiviCRM_Caldera_Forms_Relationship_Processor->pre_processor(Array, Array, '_cf_process_5fd...') #2 /example.org/wp-content/plugins/caldera-forms/classes/core.php(5213): Caldera_Forms::process_submission() #3 /example.org/wp-content/plugins/caldera-forms/classes/core.php(3831): Caldera_Forms::process_form_via_post() #4 /example.org/wp-includes/class-wp-hook.php(287): Caldera_Forms->cf_init_system('') #5 /example.org/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters(NULL, Array) #6 /example.org/wp-includes/plugin.php(484): WP_Hook->do_action(Array) #7 /example.org/wp-settings.php(579): do_action('wp_loaded') #8 /example.org/wp-config.php(102): require_once('/var/www/...') #9 /example.org/wp-load.php(37): require_once('/var/www/...') #10 /example.org/wp-admin/admin.php(34): require_once('/var/www/...') #11 /example.org/wp-admin/index.php(10): require_once('/var/www/...') #12 {main}

Did you get this resolved? I need a form where the user (employee) can see and edit a whole bunch of fields that belong to the linked organisation record.

No I never did BUT you should know that caldera forms is going bye-bye by November. A CiviCRM group is working at converting this to work with Ninja Forms (well making a new extension) so stay tuned.

Thanks for getting back. Yes, I'm aware that Caldera is on the way out, but right now I seem to have little option. If this permission thing isn't working with this plugin though then maybe I need to rethink (again).

I stumbled on a site that had this bug, and for some reason, in cf-civicrm/processors/relationship/class-relationship-processor.php:

                        'contact_id_a' => $transient->contacts->{'cid_'.$config['contact_a']},
                        'contact_id_b' => $transient->contacts->{'cid_'.$config['contact_b']},

both refer to the contact ID of contact_a, which causes an invalid relationship for the employer.

However, even if I relax that get/create code, the address/phone of the org is not being updated, so the root is probably elsewhere.