Announcement

Collapse
No announcement yet.

Relationship role

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

  • Relationship role

    Hello,

    We're setting up EspoCRM to match our workflow.
    We're going to proceed with advanced pack purchase as soon as we import all existing data and satisfied with the layout.

    So, the questions are:

    1) there is a many-to-many relationship between account and contact.
    2) account_contact has 'role' field.

    How to link account and contact via REST API specifying the 'role' field value?
    How to make Account and Contact views display those including 'role' field value?

    Would it be possible to use relationship 'role' in queries - i.e. all contacts linked with role 'x'?

    Thanks!

  • #2
    Hi,

    You need first to relate records and then update role. You can update role by updating Contact record. When you update accounts field you can specify Roles. You will need to call the same API call. There is no soecial API method that updates relationship column. But it's not difficult to implement it.

    You can display Role of contact only when you list account's contacts via listLinked request.

    Comment


    • #3
      Yuri, thank you for prompt reply!

      Unfortunately it is not clear for me without examples.

      a) Linking account and contact:

      POST Account/ACCOUNT_ID/contacts
      {
      "id" : contactId
      }

      b) How to set 'role' value for that particular link?

      Then, I've noticed, that 'role' for account-contact relationship ('role' column value) is shown as 'Title' in the account and contacts views.
      Where could I change that display name (e.g. 'Title' to 'Role')?

      However, 'role' for opportunity-contact relationship is not shown at all. What should I do to display it too?

      Thanks!

      Comment


      • #4
        I've found that Account has 'contactRole' field, and I believe I can update it.

        What I do not yet understand is how it will work for many-to-many account-contact relationship? What if I have two or more contacts linked to Account and would like to set different role for each link?

        Comment


        • #5
          As I mentioned there isn't api method that can handle this. At least I couldn't find one.

          Comment


          • #6
            You can change account roles when you update Contact record. Try to update to contact role theough UI and see what API call is made. You can see requests if you click F12 in your browser and open network tab.

            Comment


            • #7

              As I mentioned there isn't api method that can handle this. At least I couldn't find one.
              Okay, suppose I'll implement this API call.
              Then with role set for each many-to-many relationship, how to display it in the list of linked entities (as a 'Role' column)?

              Comment


              • #8
                Role available in "accountRole". Contacts panel at Account detail view.

                Comment


                • #9
                  Hello Yuri,

                  it looks like you didn't understand what I'm trying to achieve. I've made a diagram of what I have in mind.
                  Would that be possible to get with EspoCRM?

                  Thanks!

                  Comment


                  • #10
                    Yes. accountRole is available in listLinked method result.

                    Comment

                    Working...
                    X