Details
-
Type: New Feature
-
Status: Done/Fixed
-
Priority: Major
-
Resolution: Fixed/Completed
-
Affects Version/s: 1.7
-
Fix Version/s: 1.8
-
Component/s: Core CiviCRM
-
Labels:None
Description
Rationale
========
Users want to collect "Employer" information as part of a profile form. This "shortcut" to creating the related Organization contact and the relationships is available in our built-in Individual Edit form - but not available for Profile forms.
Implementation
============
NOTE: For this version - we are NOT trying to solve the problem of supporting "any relationship" with multiple related contact fields in a profile. Rather, this is a "hard-coded" solution for the specific case of entering / editing an Employer name within a profile create or edit form.
1. "Employer" is added as an option value in the "Field Name" select list WHEN "Individuals" is the selected contact type.
2. Set Defaults and Post Process rules should match what is in place for Add/Edit Individual (CRM-1246):
2.1 Post process when action = create:
- Check for existing contacts w/ type = Organization and organization_name = value entered by user
- If no match - create new contact Organization
- Create Employee Of.. relationship between new contact individual and contact organization
2.2 When action = edit:
- setDefaults():
- check for existing Employee of relationship(s). If 1 - populate org_name in form. If > 1, use the one w/ the highest relationship.id value. If 0, that field is empty.
- postProcess():
- Check if we already have Employee of relationship w/ "matching" org name. If so, no change.
- If not, just add a new contact (if doesn't exist yet) and new relationship - even if there already is one. In other words, we will just add additional Employee of relationships - but not delete/remove old ones. And since setDefault() is showing the most recently added, this will make sense to user when viewing the results...