Announcement

Collapse
No announcement yet.

How to change Relationship from "Many-To-Many" to "One-To-Many"?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to change Relationship from "Many-To-Many" to "One-To-Many"?

    Hi tanya

    Right now Contact and Opportunity Relationship is "Many - to - Many" which is default.

    My use case needs it to be "One - to - Many".

    Please help

  • #2
    And how do I disable the default relationships completely. Like contact and opportunity relationship is there, right? I want to disable it completely.

    Comment


    • #3
      I have figured it out!

      Add "skipOrmDefs": true to disable the existing relationship in entityDefs/Opportunity.json

      Then add new relationship like below. In my use case, I had to make contact to opportunity one-to-many relation

      Code:
      {
          "fields": {
              "contacts": {
                  "skipOrmDefs": true,
                  "disabled": true,
                  "customizationDisabled": true,
                  "type": "linkMultiple",
                  "view": "crm:views/opportunity/fields/contacts",
                  "columns": {
                      "role": "opportunityRole"
                  },
                  "orderBy": "name",
                  "notStorable": true
              },
              "contact": {
                  "type": "link"
              }
          },
          "links": {
              "contacts": {
                  "type": "hasMany",
                  "entity": "Contact",
                  "foreign": "opportunities",
                  "layoutRelationshipsDisabled": true,
                  "additionalColumns": {
                      "role": {
                          "type": "varchar",
                          "len": 50
                      }
                  },
                  "skipOrmDefs": true
              },
              "contact": {
                  "type": "belongsTo",
                  "foreign": "opportunities",
                  "entity": "Contact",
                  "audited": true,
                  "isCustom": true
              }
          }
      }

      skipOrmDefs will stop from creating many-many map table or fields in database level
      disabled will disable field from displaying at layouts
      customizationDisabled will disable field from displaying at entity manager.
      Last edited by theBuzzyCoder; 11-24-2018, 11:26 AM.

      Comment

      Working...
      X