sumRelated reportFilter Problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • serqet
    Senior Member
    • Feb 2019
    • 109

    sumRelated reportFilter Problem

    hello guys,

    I add formula from entities but it doesn't give report total? can you help me?

    Formula ; test1 = entity\sumRelated('Volvox', 'reportFilter5fa541ade1a44984b');

    First I created the report.
    Then I created a report filter and selected the report I created.
    And I used the ID of this filter.
  • serqet
    Senior Member
    • Feb 2019
    • 109

    #2
    Log:
    Espo.ERROR: Formula failed: [] []

    Comment

    • serqet
      Senior Member
      • Feb 2019
      • 109

      #3
      Maximus help pls

      Comment

      • Maximus
        Senior Member
        • Nov 2018
        • 2731

        #4
        Hi serqet,
        I believe you used the wrong link in your formula. The link name should started from the lower case letter like 'volvox'. See manual here please https://docs.espocrm.com/administrat...titysumrelated.
        Also, make sure that 'volvox' is the relationship name.


        Comment

        • emillod
          Active Community Member
          • Apr 2017
          • 1405

          #5
          Maximus i'm wondering if "reportFilter5fa541ade1a44984b" is correct?

          Comment


          • Maximus
            Maximus commented
            Editing a comment
            Well, it looks normal except the link name. For sure, if my suggestion will not help, then checking the filter will be the next step.
        • serqet
          Senior Member
          • Feb 2019
          • 109

          #6
          Hi Maximus ,

          first of all thank you for the answer.
          Volvox is my entity name. I guess I shouldn't use the entity name.
          Actually, I want to draw the sum I marked in the report in the picture exactly with the help of a formula and record it in a field. I could not succeed.

          Comment

          • Maximus
            Senior Member
            • Nov 2018
            • 2731

            #7
            I've noticed that your report's target Entity is Opportunity, so I assume that you have a relationship between the Volvox and Opportunity entity of One-to-Many type. In this case, the proper formula should be something like:
            Code:
            test1 = entity\sumRelated('opportunities', 'reportFilter5fa541ade1a44984b');
            Just to make sure that the Opportunity entity link called 'opportunity', open Administration -> Entity Manager -> Volvox (Relationship) -> Relation between the Volvox and Opportunity -> 'Name' parameter of the Opportunity entity.

            Please take a look one more time at this https://docs.espocrm.com/administrat...titysumrelated.

            Comment

            • serqet
              Senior Member
              • Feb 2019
              • 109

              #8
              Maximus
              I took the screenshot from the demo page to be an easy example
              I want to do this for the entity I created ...

              by the way, there is no relationship in my entity.

              Comment

              • serqet
                Senior Member
                • Feb 2019
                • 109

                #9
                Maximus this is my view... help pls.

                Comment

                • Maximus
                  Senior Member
                  • Nov 2018
                  • 2731

                  #10
                  Hi,
                  sorry for the delayed reply.

                  > by the way, there is no relationship in my entity.

                  You need to create a Relationship between the Volvox and Opportunity entity of One-to-Many type. After this, you need to add Opportunities relation subpanel to the Volvox entity and link a Volvox entity record with one or many Opportunity record/s.
                  W/o this relationship your formula won't work.

                  Comment

                  • serqet
                    Senior Member
                    • Feb 2019
                    • 109

                    #11
                    Hi Maximus

                    ​​​​​​​Unfortunately, there is no relationship that can be established between opportunities and my own entity.
                    Actually, I need the answer to this: How can I get the total number of lines I have circled in the image into a field?
                    I can pull this with sql query but I don't know how to use it in espo, maybe I can do it using hooks but I will need an example file for it.

                    Thank you.

                    Comment

                    • Maximus
                      Senior Member
                      • Nov 2018
                      • 2731

                      #12
                      Hi,
                      Now I see You don't need to Sum the total amount but you want to Count the number of records Well, to count the number of the related records you need to use this formula instead: entity\countRelated(LINK, [FILTER]) https://docs.espocrm.com/administrat...tycountrelated.

                      But you said that you don't have the relationship and you are interested in counting the total number of the records. For this purpose, there is no such formula function. You need to create a hook https://docs.espocrm.com/development/hooks/.

                      Comment

                      • serqet
                        Senior Member
                        • Feb 2019
                        • 109

                        #13
                        Hi Maximus ,

                        Glad you understand my problem
                        Yes I can use Hooks but I need help. Can you give me an example showing how to run the following query?

                        SELECT COUNT (*)
                        FROM `table_name`
                        WHERE name = "xxx" and test = "yyy" and MONTH (zzz) = MONTH (CURRENT_DATE ())
                        AND YEAR (aaa) = YEAR (CURRENT_DATE ())

                        Comment

                        • Maximus
                          Senior Member
                          • Nov 2018
                          • 2731

                          #14
                          I didn't test it but probably you will be able to achieve your purpose with this https://docs.espocrm.com/administrat...a/#recordcount.

                          Comment

                          • serqet
                            Senior Member
                            • Feb 2019
                            • 109

                            #15
                            I tried this but failed to retrieve the date field in the asset as the current month...

                            Comment

                            Working...