Announcement

Collapse
No announcement yet.

Default Team Name from Contact, possible?

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

  • Default Team Name from Contact, possible?

    Firstly, the Default Team Name is working wonderfully for our mentor/student model when mentors add records. Awesome feature.

    We do have a situation, not sure it can be solved, where the Supervisors will go into a Contact record, create a Meeting/Case/Call etc, and would like the Team Name to populate from the Contact.

    Supervisors don't have a Default Teams as they oversee all the Teams.

    So the open up Contact A belongs tot the Blue Team, add a Case for that Contact and the Team field would auto populate with Blue Team. Same with working Contacts on the Red Team, etc.

    Is that something that would go in the Entity custom script and is it upgrade safe?
    Sorry super new

  • #2
    Hi,

    You can definitely auto populate a field from an unrelated entity by writing a custom hook with a beforeSave function for any entity, so the answer to your last question is yes.

    It does require a custom script and it is upgrade safe, but I am a little confused: Team is linked to User in a many-to-many relationship but it is not linked to Contact (although a User can be linked to a Contact) or Meeting or Call or Task, so why would you need to fill a Team name for Meeting,Call,etc ?

    If possible upload a screen capture to show exactly where would you like to add this capability to better understand.

    We don't use Meetings or Calls in our application but if I can, I will try to point you to some example script or documentation that might help.

    To start here is a link to the Hook documentation https://docs.espocrm.com/development/hooks/
    Last edited by telecastg; 08-02-2020, 05:01 PM.

    Comment


    • #3
      Thank you so much telcastg for offering - attaching screen shots and here is the issue:
      Would like to auto-fill the Team with the School (Org) name for everything that is created for this Student (Contact) - It can be the exact same text as the School (Account) name

      The issue is that we can't use "default Team" for the User creating the Lesson (Case) because the user (Educator) will create lessons for all 400 students in about 20+ different Schools (Org)

      If there can be a "Default Team" process for the Student (Contact) record like there is for the User, that I think would work - maybe there is but I missed the setting?

      In practice, when a user creates a lesson for a Student, it will always be for the same Team the Student (Contact) they are creating it for belongs to

      Mentors (Users) who will perform the Lesson (Case) with the Student (Contact) belong to the Student (Contact)and both will always be on the same Team

      Presently, it seems to work only if the Educator (User) creating the Lesson (Case)selects the Team -each time- they create a lesson - (they are teaching reading/deficiencies so each lesson is customized week to week)

      There are 400 students at 2 lessons a week for each student

      So we need School (Account) = Team --> For the Lesson (Case) list and for Search

      I realize the sales model is the user is always on the same team and the contact might change companies but for this NPO it's the opposite
      Hope that makes sense in practice, thanks again for reviewing
      Attached Files

      Comment


      • #4
        Thanks for the explanation.

        I think that the confusion is the use of the assigned_user field. This field is really for internal or auditing purposes.

        In my opinion, it's better to create custom fields or entities that fit custom purposes instead of being tied to the functionality already implemented for the core entities and fields.

        I would suggest the following which can be accomplished without custom coding (for a change lol!):

        1.- Create a custom entity "School" with 2 links:
        1.1.- One-to-One Left with Team (School will have a field "team_id")
        1.2.- One-to-One Left with Account (School will have a field "account_id")

        2.- Edit the core Case entity and add two links:
        2.1.- Many-to-One with Educator (Case will have a field "educator_id")
        2.2.- Many-to-One with School (Case will have a field "school_id")

        3.- Add the fields "Educator" and "School" to the Case layout (they will show as dropdown select boxes) and remove the field "Account" (not needed since the School is already linked to Account)

        4.- Load the Teams table with the School names (One Team for each School)

        5.- Load the Schools table. If you have already loaded the Account table with the Schools information, you can import them into the new School entity, Redwood posted a great step by step guide to do that here https://forum.espocrm.com/forum/deve...ne-to-one-left

        6.- Fill the "Team" field for each School. For future School records creation, you will need to create a Team first and you can use formula or a beforeSave hook at School to automatically fill the Team name as the School name. If you are not familiar with formula, here's the link to the documentation https://docs.espocrm.com/administration/formula/

        4.- Clear cache and rebuild.

        Now when a Lesson/case is being created, the user can select an Educator and a School for it and also School has the same functionality as Team and Account because it is linked to those entities so it should be possible to search and do other things that can be done with Team or Account


        Lastly full disclosure: I didn't test this solution but wrote it based on our experience so it should work, if not at least should help you getting started. Please post your implementation when you finish to help others in the future :-)
        Last edited by telecastg; 08-02-2020, 08:16 PM.

        Comment


        • #5
          Genius level but I think I'm tracking ......one clarification,
          • ...the user can select an Educator and a School for it...
          The User creating the Student (Contact) and the Lesson (case) is always the Educator - so neither the School nor the Student will have an Educator assigned as the Educator will create Lessons (Cases) for all Students and All schools. The Mentors will only display the Lesson (Case), make a note update Status and save it. In fact all the records will only be created by an Educator.

          Does that eliminate "Many-to-One with Educator"? would it be Many-to-One with User instead?
          Last edited by crmclients; 08-03-2020, 01:28 AM.

          Comment


          • #6
            In that case you wouldn't need any link between Case and Educator and could use the Case "created_by" field (automatically filled by Espo, with the current User id when the record is created) if you need to search or another operation to link the Cases to an Educator.

            Comment

            Working...
            X