Enum for Contact Role

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • czcpf
    Senior Member
    • Aug 2022
    • 160

    Enum for Contact Role

    Hello, This question is similar to the Github discussion shown below. I would like to achieve similar functionality for the "Account" Contacts but I'm having difficulty making this work. Essentially, if you look at the image below I would like to be able to specify an enum for the Contact Role when adding new Contacts to an account. Thank you very much for your time and consideration.

    Click image for larger version

Name:	Screen Shot 2022-08-16 at 2.55.21 AM.png
Views:	483
Size:	29.9 KB
ID:	82127
    Hello, I want to achieve the functionality as given in Opportunity module by default in the custom entities created by me. What files I have to edit for that can you please suggest? So far I followed the steps from the Opportunity entity...
  • yuri
    Member
    • Mar 2014
    • 8440

    #2
    Did you try changing the type of contactRole field from varchar to enum in metadata? I believe it should work.
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

    • czcpf
      Senior Member
      • Aug 2022
      • 160

      #3
      Wow. Yes, it did work. I thought it was custom->Espo->Custom->Resources->layouts->metadata->entityDefs->Contact.json that I should create and customize field accountRole. Having trouble understanding file structures as I'm new to Espo

      This worked beautifully and thank you.

      custom->Espo->Custom->Resources->layouts->metadata->entityDefs->Account.json

      {
      "fields": {
      "contactRole": {
      "type": "enum",
      "options": ["","a","b","c"],
      "isCustom": true
      }
      }



      Click image for larger version

Name:	Screen Shot 2022-08-16 at 11.44.35 AM.png
Views:	506
Size:	46.8 KB
ID:	82141

      Comment

      • czcpf
        Senior Member
        • Aug 2022
        • 160

        #4
        Thanks for your help. I’m on my iPhone right now and can’t see how to post a new topic.

        is it possible to have documents show up with folders on Portal (ie. Portable role can view documents for account). Documents are structured on CRM with folders. However, when we assign document to an account it only has document and no folder structure. Will I need to do this manually with php ? Would you suggest creating a template for the portal with some type of filter to filter off of document type/category to display it under the dynamically generated Folders?

        Comment

        • esforim
          Active Community Member
          • Jan 2020
          • 2204

          #5
          Hi guys, do you know what happen to this field contactRole ? I want to add a few more Auto-option but it seem to be disabled now in v7.

          Am I looking at the wrong field?

          Click image for larger version  Name:	image.png Views:	0 Size:	21.3 KB ID:	92907
          Last edited by esforim; 05-26-2023, 05:52 AM.

          Comment


          • rabii
            rabii commented
            Editing a comment
            This has not changed, the field has been always a varchar. because it will difficult to predecit all job titles in the world. you can check opportunityRole on the contact entity which defines roles for contact on opportunity (it is an enum) because we can define few roles. check this Administration > Entity Manager > Contact > Fields > Opportunity Role

          • rabii
            rabii commented
            Editing a comment
            you are looking at the right field but i think they have changed it. you need to customise it (i assume in your case it is already customised you just need to add more option via code under entityDefs of Account.json (contactRole)
        • esforim
          Active Community Member
          • Jan 2020
          • 2204

          #6
          rabii thank you rabii but that is not it. Opportunity Link is only link to opportunity, I need to edit the contactRole when it link to Account Role.

          As you can see I previous made edit but now can't find it. And you can see it not the same role being used.

          Here example of my current Opportunity Role
          Click image for larger version

Name:	image.png
Views:	269
Size:	26.5 KB
ID:	92968

          Here is a search of it being test to see if it work, no result.
          Click image for larger version

Name:	image.png
Views:	247
Size:	21.4 KB
ID:	92969

          Here my current list I want to add a few more to:

          Click image for larger version

Name:	image.png
Views:	226
Size:	11.3 KB
ID:	92970

          Comment


          • rabii
            rabii commented
            Editing a comment
            esforim

            You are confusing two different relationships. there is a many to many between contact and opportunity and there you have opportunityRole on the contact which reflect the opportunity role for a contact on an opportunity record. this only exist on the opportunity > contact relationship. on the account > contact relationship they use only a varchar and not emun that's why you can only type in the value of the job title. if you wish to have similar functionality as defined in opportuntiy and contact then you need to create a new emun on the contact and call it (accountsRole should be of type emun) and use it to display the role between contact and accounts. i will double check for you if there is anyway to change this without much hassle.
        • esforim
          Active Community Member
          • Jan 2020
          • 2204

          #7
          Hi @rabii

          I think you may have misread the question! All I want to do is to add those Auto-Option/Autocomplete to the list for my Account<>Contact entity. As you can see in my screenshot I have previously done that in v5 (or was it v6) using the Admin GUI menu.

          The problem is, now I want to add in more and I can't find where is the setting to make this edit! So I'm lost.

          I'm using default field for this (no modification with code) and this was all done via GUI. At least if I remember correctly. It been like 2 years! I can't remember to be honest so I digging through the setting for it and failing miserable.

          I don't want to change it to enum which is what czpdf want to do. I just want to find where to go to make add more Auto-Option. I think I'm hijacking this thread and should have create a new thread to save the confusion?

          So all I want to do is this find how so I can add the auto-option for my Account<>Contact again, here is what I remember it should be:


          Click image for larger version  Name:	image.png Views:	0 Size:	30.1 KB ID:	93044
          Click image for larger version  Name:	image.png Views:	0 Size:	4.6 KB ID:	93045

          Comment

          • rabii
            Active Community Member
            • Jun 2016
            • 1250

            #8
            hey esforim

            I understand what you are trying to achieve but as i think that the field you are looking for is to add option will be contactRole under Account entity. one thing i noticed that the latest version of espocrm has locked that field so not sure if you will be able to add more option (unless if you customise it of course under entityDefs).
            Rabii
            Web Dev

            Comment

            • item
              Active Community Member
              • Mar 2017
              • 1476

              #9
              Hi,
              if i understand, the "options" => [] for varchar is not here.
              maybe a forget by Yuri or remove it from.

              Last edited by item; 05-30-2023, 01:04 PM.
              If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​

              Comment


              • rabii
                rabii commented
                Editing a comment
                nah i don't think this was forgotten it is intended as this field contactRole is a notsortable field and also disable (meaning can't be configured) unless if it is customised.
            • item
              Active Community Member
              • Mar 2017
              • 1476

              #10
              Hi rabii,
              yes you are right..

              if i understand i think espcrm will the same behaviours than auto-complete State, Country.. or free input without enum type field

              If you could give the project a star on GitHub. EspoCrm believe our work truly deserves more recognition. Thanks.​

              Comment

              • esforim
                Active Community Member
                • Jan 2020
                • 2204

                #11
                But I'm scare to ping him, he want busy for a few week. I have feeling it block from the UI as well! I was just hoping I'm not looking in the right setting, I tried looking through contact & account entity.

                I assume you guy never add this Auto-Complete in your version?

                Originally posted by item
                Hi rabii,
                yes you are right..

                if i understand i think espcrm will the same behaviours than auto-complete State, Country.. or free input without enum type field
                This one was only Address, I don't think anything get change yet. Maybe v7?

                Originally posted by item
                Hi rabii,
                yes you are right..

                if i understand i think espcrm will the same behaviours than auto-complete State, Country.. or free input without enum type field
                ​It still working though, I'm still using it at the moment. I just can't add more (because I can't find setting), might have to dig through the code and manual add. But being me, I don't know which .json file store this information.
                Last edited by esforim; 05-31-2023, 05:20 AM.

                Comment

                • esforim
                  Active Community Member
                  • Jan 2020
                  • 2204

                  #12
                  OK persistence prevail! It seem to be under accountRole field:
                  Click image for larger version  Name:	image.png Views:	0 Size:	18.0 KB ID:	93097
                  But no Option available though.
                  Click image for larger version  Name:	image.png Views:	0 Size:	7.1 KB ID:	93098
                  Doing a search for "contact.json" lead me to this file here:
                  [s]app/custom/Espo/Custom/Resources/metadata/entityDefs/Contact.json[/s]

                  Code:
                  app/custom/Espo/Custom/Resources/metadata/entityDefs/Account.json
                  And the json for me is like so:

                  Code:
                  "contactRole": {
                  "options": [
                  "Administration",
                  "Staff",
                  "Member of",
                  "Mother",
                  "Father",
                  "Son",
                  "Daughter",
                  "CEO",
                  "Friend",
                  "Referral"
                  ],
                  I left my list original so you guy can steal it !
                  Last edited by esforim; 05-31-2023, 05:50 AM.

                  Comment


                  • esforim
                    esforim commented
                    Editing a comment
                    This is what I thought but after saving and trying it out it still using the old list... I guess I'm still missing a secret code somewhere else.

                    Already did the usual clear cache, rebuild, log in log out, refresh window.

                    SEE 2nd comments
                    Last edited by esforim; 05-31-2023, 05:50 AM.

                  • esforim
                    esforim commented
                    Editing a comment
                    Update: the Secret is here, edit this file not Contact.json:

                    app/custom/Espo/Custom/Resources/metadata/entityDefs/Account.json
                • xdr21
                  Junior Member
                  • Oct 2024
                  • 2

                  #13
                  Has anyone gotten this to work on version 8.4.1? I am trying to have a list of Titles to choose from instead of free text.

                  Comment

                  Working...