mecachisenros / cf-civicrm

Caldera Forms CiviCRM Integration
GNU Affero General Public License v3.0
30 stars 26 forks source link

Invalid Relationship when adding 2 contacts where one is an organization #195

Open shaneonabike opened 3 years ago

shaneonabike commented 3 years ago

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}`

Upperholme commented 3 years ago

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.

shaneonabike commented 3 years ago

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.

Upperholme commented 3 years ago

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).

mlutfy commented 2 years ago

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.