Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-13725

Make check for duplicate relationship aware of custom fields

    Details

    • Type: Improvement
    • Status: Done/Fixed
    • Priority: Critical
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.4.1
    • Fix Version/s: 4.7
    • Component/s: Core CiviCRM
    • Labels:
    • Documentation Required?:
      None
    • Funding Source:
      Contributed Code

      Description

      This issue is related to this forum discussion: http://forum.civicrm.org/index.php/topic,30451.0.html

      Suppose I have a relationship 'has function at' between a contact and an organization. This relationship has a custom field, a string from a drop-down list which describes the particular function.

      Suppose that from today on, I have two functions (A and B) in the same organization. I don't know yet for how long I will have those functions, but probably I will have function A longer than function B. Now I cannot enter both functions in CiviCRM, because it will complain about a duplicate relationship, although the value of the custom field will differ for both relations.

      Now if I do know in advance that I will have function A till end this year, and function B for two years, and I enter the end dates, CiviCRM does not complain, because both relationships have different end dates, and are not considered duplicates.

      I found this strange.

      We had a discussion on the forums, and Lobo suggested to implement this with a hook. Eileen suggested to fix it in the form layer.

      In our effective implementation, we hacked around the problem by making the function field multi-value, and breaking up relationships into consecutive pieces when someone has multiple functions at the same time.

      But since I want to learn about civicrm, I tried to write some kind of fix for this problem. I don't know a lot about hooks or forms yet, so I just did the following:

      • I added a boolean to each relationshiptype: custom_field_dupe_check. If it is set, the value of custom fields are taken into account when checking for booleans.
      • I modified the form for relationshiptype, so that the user can set and clear this boolean.
      • In the BAO, I adapted the check for duplicates function so that it looks at the custom field values when the boolean is set.

      I will upload a patch in a minute.

      Now I guess I'd better create an extension for this, because it is not really clear whether/how this could be fixed in CiviCRM core. And then probalby hooks will come into play.

      I don't have a lot of spare time to develop on this. But I will try to polish this. If in the mean time you have hints or suggestions, please let me know.

        Attachments

          Activity

            People

            • Assignee:
              colemanw Coleman Watts
              Reporter:
              johanv Johan Vervloet
            • Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: