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 Drupal Modules (Moderator: Donald Lobo) »
  • Webform CiviCRM: create employer + optionally another relationship
Pages: [1]

Author Topic: Webform CiviCRM: create employer + optionally another relationship  (Read 2477 times)

davej

  • Ask me questions
  • ****
  • Posts: 404
  • Karma: 21
Webform CiviCRM: create employer + optionally another relationship
February 11, 2014, 10:48:45 am
Hi,

Trying to use Webform CiviCRM for the following requirement...

- Create Individual with "Employee of" + optionally another relationship to an existing Organization, chosen with an autocomplete field. The user interface should show only the optional additional relationship type, not "Employee of".

Tried following setup:

Contact 1: Person (Individual)
- the new Ind. being created.
- has Current Employer field set to Company; this field is an autocomplete with:
    - Set default contact from: Relationship to Person,
    - Specify Relationship(s): Employer of Person,
    - Filter - Type of Organization: Company.
Contact 2: Company (Organization, subtype Company)
- has Relationship to Person: User Select (non-mandatory field with the 2 additional relationship type options).

So essentially, trying to use two different means to create the relationships: one for Employer of, one for the optional additional user-selectable relationship.

Result: only the "Employer of" relationship is created.

Would this be expected to work in the way described? If not, is there a better way? A hacky option might be to make use of the facility to have multiple relationship types and do some meddling with the UI to hide "Employer of" from the user but still have it created behind the scenes. But it would be nice to avoid that sort of shenanigans.

Many thanks,

Dave

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Webform CiviCRM: create employer + optionally another relationship
February 11, 2014, 12:02:22 pm
1. Yes it ought to work as you describe. I'm not sure why the additional relationships would not be created, but it could be a bug. Can you check your drupal watchdog log?

2. I don't think the backend option selection you described is needed in light of #1, but for the record, doing that sort of thing isn't really shenanegans with webform_civicrm. It's a build-in feature. On the admin form (civicrm tab) you can select for relationship type both "user select" and additional options. The ones you check on the admin form will be hidden from the front-end webform and automatically submitted in addition to whatever the user chooses. This works with any multivalued field. If you click the help bubble next to a multivalued field, it will tell you so :)
Try asking your question on the new CiviCRM help site.

davej

  • Ask me questions
  • ****
  • Posts: 404
  • Karma: 21
Re: Webform CiviCRM: create employer + optionally another relationship
February 12, 2014, 07:52:12 am
Hi Coleman,

Many thanks for your helpful response.

Quote from: Coleman Watts on February 11, 2014, 12:02:22 pm
1. Yes it ought to work as you describe. I'm not sure why the additional relationships would not be created, but it could be a bug. Can you check your drupal watchdog log?

Thanks for confirming that this method should work, that's always useful to know! The following PHP notice is logged when the Employer autocomplete is filled in:

Code: [Select]
Notice: Undefined offset: 1 in wf_crm_webform_base->loadContact() (line 114 of .../webform_civicrm/includes/wf_crm_webform_base.inc).
I added some extra watchdogs in loadContact() and found:

Code: [Select]
loadContact: $contact['number_of_relationship'] = '1'

loadContact: before $this->getRelationship, $c = '2', $r = '1', $cid = '15233', $types = Array ( )

loadContact: before $this->getRelationship, $this = wf_crm_webform_ajax Object
(
...[snip]...
    [id:protected] => Array
        (
            [cid] => Array
                (
                    [2] => 15233
                    [0] => 15233
                )
        )
...[snip]...
)

So the "Undefined offset: 1 in wf_crm_webform_base->loadContact()" occurs because $this->id['cid'][$r] doesn't exist, where r = 1. $this->id['cid'] just has 0 and 2, both with the ids of the Company.

The only watchdog errors on submit are dozens of these from webform_conditional:
Notice: Undefined index: value in _webform_conditional_get_all_components() (line 662 of .../webform_conditional/webform_conditional.module).
There are no conditional actions on this form.

Quote from: Coleman Watts on February 11, 2014, 12:02:22 pm
2. I don't think the backend option selection you described is needed in light of #1, but for the record, doing that sort of thing isn't really shenanegans with webform_civicrm. It's a build-in feature. On the admin form (civicrm tab) you can select for relationship type both "user select" and additional options. The ones you check on the admin form will be hidden from the front-end webform and automatically submitted in addition to whatever the user chooses. This works with any multivalued field. If you click the help bubble next to a multivalued field, it will tell you so :)

Thanks, also very useful to know. I failed to mention one further requirement: the Org should be set as the Individual's current employer.

I tried method 2 by making the following changes to the webform:

- In Webform tab, settings for Employer field, changed: "Set default contact from" from "Relationship to Person" to "None".
- In Civi tab, Contact 2 (Company), Relationship to Person, changed from single-select "User Select" to multi-select with both "User Select" and "Employer of" selected.
- In Webform tab, expected available options for "Relationship to Person Relationship Type(s)" field to have changed (i.e. "Employer of" not to be available), but there was no change. This field was set for static options but I changed that to dynamic to see if the available options had changed.
==> Re-tested, same problem as original set-up: only "Employer of" relationship created. The same PHP notice occurred when completing the Employer field.

- In Webform tab, deleted "Relationship to Person Relationship Type(s)" field.
- In Civi tab, Contact 2 (Company), Relationship to Person, again changed from single-select "User Select" to multi-select with both "User Select" and "Employer of" selected => this recreated field Relationship to Person Relationship Type(s).
- In Webform tab, "Relationship to Person Relationship Type(s)" field, set to single select with desired static options (as we want the labels to differ from the relationship type names).
==> Re-tested, same problem as original set-up: only "Employer of" relationship created. The same PHP notice occurred when completing the Employer field. :-(

EDIT: webform_civicrm version is 7.x-4.5, Civi 4.4.1 .

Cheers,

Dave
« Last Edit: February 12, 2014, 09:05:25 am by davej »

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Webform CiviCRM: create employer + optionally another relationship
February 12, 2014, 11:27:41 am
Quote
The only watchdog errors on submit are dozens of these from webform_conditional
You should uninstall and remove webform_conditional - it is not compatible with webform v4, which has a built-in conditional feature.
Try asking your question on the new CiviCRM help site.

davej

  • Ask me questions
  • ****
  • Posts: 404
  • Karma: 21
Re: Webform CiviCRM: create employer + optionally another relationship
February 13, 2014, 05:10:05 am
Hi Coleman,

Quote from: Coleman Watts on February 12, 2014, 11:27:41 am
You should uninstall and remove webform_conditional - it is not compatible with webform v4, which has a built-in conditional feature.

Thanks, I have disabled, uninstalled and removed the code of webform_conditional. Re-tested and the behaviour is still the same: only the "Employee of" relationship is created.

Cheers,

Dave J

davej

  • Ask me questions
  • ****
  • Posts: 404
  • Karma: 21
Re: Webform CiviCRM: create employer + optionally another relationship
February 28, 2014, 02:30:38 am
Hi Coleman,

Hope you'll excuse the bump, any thoughts on this issue? Uninstalling and removing webform_conditional didn't help; any thoughts on the debugging info in my post of February 12, 04:52:12 pm ?

Thanks,

Dave

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Webform CiviCRM: create employer + optionally another relationship
March 10, 2014, 02:40:45 pm
I tried and failed to reproduce the issue.
Screenshots attached showing everything working normally.
Try asking your question on the new CiviCRM help site.

davej

  • Ask me questions
  • ****
  • Posts: 404
  • Karma: 21
Re: Webform CiviCRM: create employer + optionally another relationship
April 29, 2014, 08:45:27 am
Hi Coleman,

Sorry for the delay in responding. Thanks for trying to replicate the issue. I was able to get it working with your simple test case and have tracked down what was happening on the original webform. This is a longish form and the Relationship Type field is some way above the Existing Contact field. When a contact is selected for Existing Contact, the Relationship Type field gets unset. So unless the user notices this and goes back and re-selects the desired additional relationship type, the additional relationship doesn't get created. D'oh!

We then found a further issue regarding inheriting memberships, I'll post separately about that.

Cheers,

Dave

davej

  • Ask me questions
  • ****
  • Posts: 404
  • Karma: 21
Re: Webform CiviCRM: create employer + optionally another relationship
May 08, 2014, 07:56:57 am
Hi Coleman,

A quick follow-up question if I may.

When using the webform to edit an existing individual with 2 existing relationships to an existing company (employee + second relationship type), the relationship type field pre-populates with the second relationship type - great. (The relationship type field is a single select with static options, which excludes employer, which is set via Current Employer in Contact Fields.)

If the user un-selects the second relationship type on the webform & saves, the desired behaviour is that the second relationship should be removed. This doesn't happen, both relationships remain. Would you expect it to be removed?

Regards,

Dave J

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Drupal Modules (Moderator: Donald Lobo) »
  • Webform CiviCRM: create employer + optionally another relationship

This forum was archived on 2017-11-26.