Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autofill related contacts on same page #284

Conversation

nishant-bhorodia
Copy link
Contributor

Overview

I have a webform where 5 contacts are added with relations as below:

  • Contact 2 (Organization) is an Employer of Contact 1 (individual)
  • Contact 3 (Individual) is Parent of Contact 1 (Individual)
  • Contact 5 (Organization) is an Employer of Contact 4 (Individual)

How it works

  • Contact 2 gets auto-filled when Contact 1 is selected.
  • Contact 3 is not auto filled with the parent of Contact 1.
  • Contact 5 is not auto filled with employer of Contact 4.

The above scenarios work fine where there is a page break on the webform but not when on the same page.

How it should work

  • Contact 2 gets auto-filled with the employer when Contact 1 is selected.
  • Contact 3 gets auto-filled with the parent of Contact 1.
  • Contact 5 is auto-filled with the employer of Contact 4.

Before

before

After

after

Technical Details

  1. Condition here: https://github.com/colemanw/webform_civicrm/blob/7.x-5.x/includes/wf_crm_webform_ajax.inc#L137 only checks for $c == 1 which makes autofill work for only Contact Removing $c == 1 makes it work for all contact fields.
  2. In function wf_crm_find_relations it was giving zero results if relationship type was anything other than employee/employer. It happened because the parameters were missing the contact id parameter. Used $cid to fetch relatioships for given contact id.

@jamienovick
Copy link

jamienovick commented Jan 8, 2020

@colemanw @KarinG would be great to get this bug fix reviewed if possible.

@colemanw colemanw merged commit 8a4216d into colemanw:7.x-5.x Jan 10, 2020
@colemanw
Copy link
Owner

Thanks for the fix. I tested this out and it works :)

@colemanw
Copy link
Owner

@KarinG I also cherry-picked these commits into the 8.x branch.

@jamienovick
Copy link

@colemanw @KarinG thanks guys; much appreciated.

@nishant-bhorodia
Copy link
Contributor Author

Thanks @colemanw @KarinG @jamienovick :)

@colemanw
Copy link
Owner

FYI @jamienovick this went into the 7.x-5.0 release.

omarabuhussein added a commit to compucorp/webform_civicrm that referenced this pull request Jan 19, 2020
omarabuhussein added a commit to compucorp/webform_civicrm that referenced this pull request Jan 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants