Announcement

Collapse
No announcement yet.

how to use the filter in entity\countRelated and entity\sumRelated

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

  • how to use the filter in entity\countRelated and entity\sumRelated

    I see the following example in https://www.espocrm.com/documentatio...ation/formula/

    entity\countRelated('opportunities', 'open')

    it should be used to count the number of opportunities, where is the meaning of the filter parameter 'open' ? which opportunities record will be counted?

    Thanks.


  • #2
    i've got the answer
    Hi, in documentation there is a example for entity\sumRelated function in formula: entity\sumRelated(LINK, FIELD, [FILTER]) Sums related records by a

    Comment


    • #3
      Originally posted by Vincent View Post
      No way. This could be easier for who is not a programmer. Why not having filter as an Attribute condition, like "fieldx == 1"

      Is is possible to implement this?

      Comment


      • #4
        Hello.

        I'm having problems using this formula. I split this post in two pieces as I have surpassed the max number of attachments

        This is part 1

        I have two entities: WCOrders and WCOrderLine with a relationship 1-N

        Click image for larger version

Name:	Relacioes.JPG
Views:	873
Size:	83.7 KB
ID:	49460


        I launch a Process related to a saved WCOrder with the attached Flowchart.

        Click image for larger version

Name:	flowchart.JPG
Views:	825
Size:	66.1 KB
ID:	49461

        At the end of the Process I ask for obtaining a summary of the quantities included in all the the related WCOrderLines using the formula sumRelated. I have 6 additions and 6 different filters.

        Click image for larger version

Name:	Formula 1.JPG
Views:	929
Size:	72.6 KB
ID:	49458
        Click image for larger version

Name:	Formula 2.JPG
Views:	830
Size:	68.1 KB
ID:	49459

        End of Part 1

        Comment


        • #5
          Part 2


          I have already defined the report filters, They filter based on the Field lGTipoProducto . It is a List Field and may have 6 different values. I´m copying only one Report Filter.

          Click image for larger version

Name:	ReportFilter.JPG
Views:	830
Size:	85.9 KB
ID:	49466


          The issue is that in my example I have 3 Order Lines with 3 different lGTipoProducto with Quantities 1, 1 and 2. (Total for all orderLines is 4)

          And the output of the formula sumRelated for any of the posssible values of lGTipoProducto is the same: 4

          Click image for larger version

Name:	Resultado.JPG
Views:	847
Size:	66.1 KB
ID:	49465
          This seems to me that the filter is not working and is adding all the quantities of all the related records regardless their lGTipoProducto.

          But if I look at the reports they are working fine. They are providing the expected output.
          Click image for larger version

Name:	ReportOutput.JPG
Views:	921
Size:	39.0 KB
ID:	49463

          So seems I'm not making the right reference to the filter. But I don't see anything wrong in the expression.

          M ay you help me to spot the mistake?

          Thank you very much in advance


          Attached Files

          Comment


          • #6
            Hello no need assistance on this any longer. I found it.

            In case anyone is interested there are two steps on this.

            First. You need to define a Report. This report has the filter you need.

            Second. Then you need to define a Report Filter (directly with thin name in Administration). In that Report Filter you address the Report defined first.

            Comment

            Working...
            X