Answers.Body: <p>If you want a custom "Contact Reference" field to <em>always</em> create a relationship whenever it is saved, you would need to add some custom code implementing <a href="http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_post" rel="nofollow">hook_civicrm_post</a>.</p>
  
  <p>However, before you go down that road I suggest you clarify why you want to create both a custom field <em>and</em> 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.</p>
  
  <p>I suggest you decide to use a custom "Contact Reference" <em>or</em> a custom relationship type, and not both. Trying to store the same data in 2 places is rarely worth the trouble it causes.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-19T21:58:29.273Z
Answers.Text: 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?
Answers.UserDisplayName: alec
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-20T00:45:30.713Z
Answers.Text: @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.
Answers.UserDisplayName: Coleman
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-19T14:13:38.397Z
Answers.LastActivityDate: 2015-06-19T19:09:27.910Z
Answers.LastEditDate: 2015-06-19T19:09:27.910Z
Answers.UserDisplayName: Coleman
Answers.Body: <p>If you are using Drupal then the <a href="https://www.drupal.org/project/webform_civicrm" rel="nofollow">Webform-CiviCRM</a> 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 <a href="http://wiki.civicrm.org/confluence/display/CRMDOC/Webform+CiviCRM+Integration" rel="nofollow">excellent documentation</a>.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-19T03:11:33.693Z
Answers.Text: 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?
Answers.UserDisplayName: alec
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-19T03:12:59.607Z
Answers.Text: 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.
Answers.UserDisplayName: alec
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-19T06:54:06.177Z
Answers.Text: I meant Drupal Webform_civicrm. Not sure about Price Sets. But no, not needing Rules, the webform-civicrm integration does all that beautifully
Answers.UserDisplayName: petednz - fuzion
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-19T13:40:06.640Z
Answers.Text: Please [edit](http://civicrm.stackexchange.com/posts/3384/edit) your post to explain *how* it can be done. Simply giving the name of a third party module is not especially helpful.
Answers.UserDisplayName: choster
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-06-19T02:21:14.343Z
Answers.LastActivityDate: 2015-06-20T00:48:32.950Z
Answers.LastEditDate: 2015-06-20T00:48:32.950Z
Answers.UserDisplayName: petednz - fuzion
Body: <p>Is there a way to create in a new custom field the functionality in an Individuals "Current Employer" field?</p>
  
  <p>For example, trying to create a generic "Organizational Affiliation"...</p>
  
  <p>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?</p>
  
  <p>Then this field could be added to profile for use contribution page for membership signup.</p>
  
  <p>Edit: This is on Drupal.</p>
  
  <p>Edit: This question turning into "How to create relationships between contacts on contribution pages?" I started out saying "in a new custom field" but <em>new custom field</em> 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.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-06-19T03:42:17.523Z
Comments.Text: 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.
Comments.UserDisplayName: JoAnne
Tags: <contacts><custom-fields>
Title: field like "Current Employer" that creates new organization and relationship
ThreadText: # field like "Current Employer" that creates new organization and relationship
  
  (Asked by: username_0 on 2015-06-18)
  
  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 @username_2 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.
  
  **Tags:** contacts, custom-fields
  
  > **Comments:**
  > **username_1**: 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.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2015-06-19. Score: 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](http://wiki.civicrm.org/confluence/display/CRMDOC/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.
  
  > **Comments:**
  > **username_0**: Thanks @username_2.  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?  
  > **username_2**: @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.  
  
  ---
  
  ### Answer by username_3 on 2015-06-19. Score: 2
  
  If you are using Drupal then the [Webform-CiviCRM](https://www.drupal.org/project/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](http://wiki.civicrm.org/confluence/display/CRMDOC/Webform+CiviCRM+Integration).
  
  > **Comments:**
  > **username_0**: 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?  
  > **username_0**: 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.  
  > **username_3**: I meant Drupal Webform_civicrm. Not sure about Price Sets. But no, not needing Rules, the webform-civicrm integration does all that beautifully  
  > **username_4**: Please [edit](http://civicrm.stackexchange.com/posts/3384/edit) your post to explain *how* it can be done. Simply giving the name of a third party module is not especially helpful.  
  
  ---
  
  