Announcement

Collapse
No announcement yet.

Automatically setting the filter when selecting entity records

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

  • Automatically setting the filter when selecting entity records

    Hi,

    This is our scenario:


    Entities in CRM
    -----------------------------
    (1) Account: We have 2 types of accounts - Corporate and Insurers
    (2) The Type field in account indicates the type of account
    (3) The same company can be an insurer and a corporate (created as 2 records)
    (2) Policy: Containing insurance info and has a many-to-one relationship with Account.

    What we need to do:
    ------------------------
    When we create a Policy we need to select the related insurer in Account which has the account.type field as "Insurer"

    Current Scenario:
    ---------------------
    When creating the Policy, the staff select the account they get a list of all the accounts (mixed corporate and insurer). They then have to apply a filter to show only the insurer type accounts and select.

    Problem definition:
    -----------------------
    When selecting the account. the staff inadvertently select the the corporate type instead of the insurer type.

    Resolution required:
    ----------------------------
    Is there a way (formula or otherwise) where we could set the filter on the type when selecting the account instead of manually setting the filter. Benefit: reduction of errors by 50%.​

    Any help/advise is most appreciated.
    Last edited by murugappan; 03-03-2024, 03:44 AM.

  • #2
    Hi,

    It requires a little bit of coding. See a related topic: https://forum.espocrm.com/forum/deve...current-record.

    Comment


    • #3
      yuri thank you for the update and the reference link.

      Unfortunately, it may not work for us. Reason is the coding required and the fear of failure on version upgrades which may not be compatible to these codes. We would like to keep things simple and conform to the standard of Espocrm thereby avoiding any upgrade issues. We are already facing this issue with some of the extensions which we purchased. It catches us by surprise when we upgrade and the system crashes during our development for new requirements. We had to drop these extensions in our currenr re-engineering project to avoid delays. Everything comes to a halt until we get a fix which we could not afford.

      Suggestion:

      Our suggestion would be to make filter options available in relationships or in the custom list layout for relationship. That way it becomes flexible, consistent and ensures maintainability.

      Comment


      • #4
        The method is official and is supposed to be compatible in future.

        > That way it becomes flexible, consistent and ensures maintainability.

        This is not a magic. The flexibility and consistency would be an additional work imposed on me.

        Comment


        • #5
          You can specify a primary filter through metadata: https://docs.espocrm.com/development...tionshippanels, selectPrimaryFilterName​. No coding needed.

          custom/Espo/Custom/Resources/metadata/clientDefs/YourEntityType.json

          Code:
          {
              "relationshipPanels": {
                  "yourLinkName": {
                       "selectPrimaryFilterName": "myFilterName"
                  }        
              }
          }
          Primary filters can be created with the Report Filters feature from Advanced Pack, or by coding.

          When you create a Report Filter, a primary filter with a name "reportFilterXXXXXXXXXXXXXX" is created, where the X part should be replaced with an ID of the Report Filter record (can be obtained from the browser's location bar).

          This method is 99% future proof.
          Last edited by yuri; 03-03-2024, 04:06 PM.

          Comment


          • #6
            yuri

            I tried the option of using the report filter but it did not work. I must have done something wrong: This is what i did:

            Click image for larger version

Name:	Relationship.jpg
Views:	317
Size:	46.5 KB
ID:	103325 Click image for larger version

Name:	Report.jpg
Views:	266
Size:	74.2 KB
ID:	103326 Click image for larger version

Name:	Report Filter.jpg
Views:	271
Size:	38.7 KB
ID:	103327 Click image for larger version

Name:	metadata.jpg
Views:	270
Size:	47.4 KB
ID:	103328 Click image for larger version

Name:	Create Notification.jpg
Views:	273
Size:	66.8 KB
ID:	103329

            The metadata definition is in the Company Notification entity.

            Comment


            • Kharg
              Kharg commented
              Editing a comment
              When you create a Report Filter, a primary filter with a name "reportFilterXXXXXXXXXXXXXX" is created, where the X part should be replaced with an ID of the Report Filter record (can be obtained from the browser's location bar).

              So I think that you have to add the ID as well, such as "FilterInsurerXXXXXXXX"

            • yuri
              yuri commented
              Editing a comment
              F̶i̶l̶t̶e̶r̶I̶n̶s̶u̶r̶e̶r̶XXXXXXXX -- wrong. It's not how I described.


          • #7
            1. The name should be "reportFilterXXXXXXXXXXXXXX", where XXXXXXXXXXXXXX is an ID of the Report Filter record.
            2. For your case, If you need the filter to be applied for the link field, you need to define it in the opposite entity type ('CompanyNotification').

            Comment


            • #8
              yuri Kharg

              Very interesting as I got it work partially but the result came with an error. Please allow me to follow through the steps again (because i made a few mistake earlier):

              (1) Setup relationship between Company Notification entity and Company entity

              Click image for larger version

Name:	1. Relationship.jpg
Views:	326
Size:	46.5 KB
ID:	103338

              (2) I created a list report "FilterInsurer" which contains the filter

              Click image for larger version

Name:	2. Report.jpg
Views:	245
Size:	74.2 KB
ID:	103339

              (3) I created a Report Filter "FilterInsurer"

              Click image for larger version

Name:	3. Report Filter.jpg
Views:	248
Size:	38.7 KB
ID:	103340

              (4) I define the Primary filter in the Company Notifications entity

              Click image for larger version

Name:	4. metadata.jpg
Views:	242
Size:	49.7 KB
ID:	103341

              (5) I go the front end and create a Company Notification and select a company (which should give me a list "insurer")

              Click image for larger version

Name:	5. Create Noty.jpg
Views:	238
Size:	66.8 KB
ID:	103342

              (Continued on next post)
              Last edited by murugappan; 03-04-2024, 08:49 AM.

              Comment


              • #9
                yuri Kharg

                Sorry had to split into 2 posts as there is a limitation on number of uploads

                (6) I get an error message

                Click image for larger version

Name:	6. Error Message.jpg
Views:	252
Size:	24.6 KB
ID:	103344

                (7) I cancel the error and Select the dropdown and selected the "FilterInsurer" option not the one with ID) and it listed the "insurer" only

                Click image for larger version

Name:	7. Dropdown.jpg
Views:	230
Size:	41.5 KB
ID:	103345

                Comment


                • Kharg
                  Kharg commented
                  Editing a comment
                  Use ReportFilterXXXXXX as Yuri suggested

                • yuri
                  yuri commented
                  Editing a comment
                  "reportFilterXXXXXXXX". Case matters ALWAYS. I'm baling out. Need to work.

                • murugappan
                  murugappan commented
                  Editing a comment
                  yuri Kharg i misunderstood "reportFilterXXXXXXXXX". and replaced the "reportFilter" portion. The "reportFilter" part is a constant. The "XXXXXXX" is the variable part which is to be replaced with the filter ID obtained from the Browser URL when viewing the report filter. Corrected the mistake and it is working great now. Thank you for all the help.
                  Last edited by murugappan; 03-04-2024, 01:16 PM.
              Working...
              X