2

Is there a way to create in a new custom field the functionality in an Individuals "Current Employer" field?

For example, trying to create a generic "Organizational Affiliation"...

How to create the relationship between the Individual and this Organization? And if the organization does not already exist then to create it on-the-fly?

Then this field could be added to profile for use contribution page for membership signup.

Edit: This is on Drupal.

Edit: This question turning into "How to create relationships between contacts on contribution pages?" I started out saying "in a new custom field" but new custom field isn't important and as @Coleman points out is bad idea. But some sort of field that allows constituent to enter name of another contact they're related to and have the relationship get created upon form submission.

  • it better to edit the orginal question to include details such as CMS rather than add them in a comment. If you are concerned that it might then make Pete's answer seem a little crazy you can edit as I have done. – JoAnne Jun 19 '15 at 3:42
3

If you want a custom "Contact Reference" field to always create a relationship whenever it is saved, you would need to add some custom code implementing hook_civicrm_post.

However, before you go down that road I suggest you clarify why you want to create both a custom field and a relationship to store the same data. Is it just because that's what the "Current Employer" field does? Not a great reason in my opinion. It's generally a bad practice to store the same data in two places, so the overly-complex "Current Employer" field is not setting a great example of tidy database practices.

I suggest you decide to use a custom "Contact Reference" or a custom relationship type, and not both. Trying to store the same data in 2 places is rarely worth the trouble it causes.

  • Thanks @Coleman. I'm more interested in having this data in a custom relationship type than having it in a custom field stored on the contact. I was just imagining/hoping that there would be a way I can have an input (in a field, a profile, non-"field" text input, civi-relationship-wizomatic, anything) that would allow a new member to type the name of an organization they're affiliated with and a text field for their role/position in that affiliation while they're joining as a member on a contribution page. How can that be done? – alec Jun 19 '15 at 21:58
  • @petednz's answer explains how you can do this. Set up your membership form using webforms and it will be easy to let the user enter related contacts. – Coleman Jun 20 '15 at 0:45
2

If you are using Drupal then the Webform-CiviCRM module can be used to allow user to add their Employer, or find an existing organisation, and create a relationship of 'employee of' between them. Works equally well with a custom relationship type you define. This is well explained in the excellent documentation.

  • Using just webform? Or using webform+rules? It seems like webform would collect the data, but wouldn't something else (like a rule) be required to create the organization and the relationship? – alec Jun 19 '15 at 3:11
  • I've seen lots of mention of using Drupal's webforms but I think I read somewhere that price sets can't be used on them. – alec Jun 19 '15 at 3:12
  • I meant Drupal Webform_civicrm. Not sure about Price Sets. But no, not needing Rules, the webform-civicrm integration does all that beautifully – petednz - fuzion Jun 19 '15 at 6:54
  • 2
    Please edit your post to explain how it can be done. Simply giving the name of a third party module is not especially helpful. – choster Jun 19 '15 at 13:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.