Announcement

Collapse
No announcement yet.

how to set "master" filter for a bunch of child entities with one parent entity?

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

  • how to set "master" filter for a bunch of child entities with one parent entity?

    Advanced Pack 2.5.14
    EspoCRM Version 5.9.3

    Hello!

    I am at the beginning of working with filters, so there might be a wellknown solution to my problem and I just did not find it...

    My situation:
    Custom Parent entity: projekte

    Some 25 custom child entities, all linked to the parent entity.

    In my business there are inspectors who visit the customers and check the worksite for work safety issues. Depending on the issue they use one or more of our custom entities to make their documentation. It might happen, that the inspector spends a whole day at the customer site and has to create many new records in different child entities.

    In order to get the record of the child entity assigned to the correct project, the inspector has to choose always the same project in the detail mask of the child entity.

    How can I manage, to let the inspector select the correct project (parent entity) only once a day in the morning, and do all the documentation in the child entites without selecting a wrong parent entity.

    I would need to preset the parent entity and as long as it is not changed, all created records of the child entities are automatically assigned to the correct parent entity.

    I hope I could let you understand what I need,


    Thank you!

  • #2
    Hello Gustav,
    So you need that the proper project would be set automatically for the subtask to avoid the situation when the inspector may link to the wrong project. Is that correct? If so, I have a few questions:
    1. Does there only one project for a day for one inspector?
    2. You have many inspectors, so does it mean that each inspector has its own project for a day?

    Comment


    • #3
      Hi Maximus!

      Yes, I have to avoid that the inspector links to the wrong project!

      ad 1. No, the inspector could have up to three projects a day. In total there are up to 40 or 50 projects assigned to the inspector and he always has to select from the list of 40 for each record he makes.
      ad 2. Yes, each inspector has one or more projects a day.

      Thank you!

      Comment


      • #4
        Another way to describe the problem:

        When the inspector chooses one project, he should only have filtered access to the lists and detail views of this project. When he works on the next project, he should have filtered access to all the lists and detail views of the next project and so on...

        Comment


        • #5
          I have a simple idea:
          1. Create a relation (one-to-one Right or Left) between the User and Project entities. Lets label the Project relation as 'Current Project' for instance.
          2. Go to the Layout Manager -> User -> Detail -> add the 'Current Project' field to the layout.
          3. Go to Entityt Manager -> Sub-projects -> Add formula something like this:
          Code:
          ifThen(
              entity\isNew() && createdBy.projectId,
              projectId = createdBy.projectId
          )
          So, when your inspector starts to work on some project, he opens his profile and selects the desired project. Then he goes and creates the sub-projects. The proper Project will be auto-populated to Sub-project upon saving the record. When the inspector starts to work with another one project, he opens his profile again and changes the Current Project.

          Comment


          • #6
            Hi gustavgraz , I liked your question!

            I am sure it helps in many cases, I found this solution,

            1 - go to entity manager => User => links => add link with your project entity
            2 - go to entity manager => OneOfYourChildEntities => fields => the project link field => edit the default value to the following:

            javascript: return this._user.get('projectId');


            3 - repeat the second step for the rest of child entities.

            The user will need to set the project one time and all the links will refers to the same value till he change his profile again.

            NOTE: projectId may has to be projekteId, this depends on the project link name in the user entity!

            UPDATE: the default value must be set manually to the entityDef json file.

            Best Regards
            Last edited by eymen-elkum; 09-09-2020, 10:38 AM.
            CEO of Eblasoft
            EspoCRM Expert since 2014
            Full Stack Web Developer since 2008
            Creator of Numerous Successful Extensions & Projects​

            Comment


            • #7
              Many thanks to both of you! I will work on that and report about problems/success!

              Comment


              • #8
                Ok, working on Eymens step by step guide:

                Step 1
                - go to entity manager => User => links => add link with your project entity

                I have set up this relation already before. In my case I took an n:n relationship.

                users n:n projekte

                Does that make a difference? Should it be a different relationship?


                Step 2
                2 - go to entity manager => OneOfYourChildEntities => fields => the project link field => edit the default value to the following:

                javascript: return this._user.get('projectId');

                The first Child Entity I choose is "Brandschutzprotokoll"
                Go to Brandschutzprotokoll => Felder => projekte => I think the "default value" is called "Standard"

                I try to get the formula in this field and I cannot safe it!

                See the pic please. Am I using the wrong place to paste the formula in?

                Thank you!

                Comment


                • #9
                  Originally posted by gustavgraz View Post
                  Does that make a difference? Should it be a different relationship?
                  Yes, must be users n:1 projekte

                  User has one project.

                  I try to get the formula in this field and I cannot safe it!
                  I am sorry, forgot about this, you have to set this value manually, if no FTP access you will need extension!
                  I think the extension will replace the default value input from link to free text
                  Last edited by eymen-elkum; 09-09-2020, 10:36 AM.
                  CEO of Eblasoft
                  EspoCRM Expert since 2014
                  Full Stack Web Developer since 2008
                  Creator of Numerous Successful Extensions & Projects​

                  Comment

                  Working...
                  X