Announcement

Collapse
No announcement yet.

Filtering for Formula entity\sumRelated (non-developers)

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

  • Filtering for Formula entity\sumRelated (non-developers)

    Hi,

    For the formula: entity\sumRelated(LINK, FIELD, [FILTER]) how can I correctly use the optional filter? I would like to assign a specific field to the filter like "myfield=value" (for an enum)

    I've tried creating a filtered report and then using the Report Filter ID within the filter section (entity\sumRelated('opportunities', 'amountConverted', 'reportFilter7c45454545454545'), but this isn't working.

    Does anyone have suggestions? I'm not a developer so preferably the solution won't require me going into the code. Thank you!

  • #2
    Hi,
    Please provide screenshots of how you configured Report, Report filter, Formula to find out the issue.
    It should work for the Enum type filed.

    Comment


    • #3
      Hi Maximus

      The first screenshot is based on the field filter that Basis = Recurring. The workflow is calculating all transactions though.

      The second screenshot is scheduled based off a report that only includes transactions with a Basis = Recurring. This still results in the sum of all transactions and not just transactions that are Recurring.

      Thank you!
      Attached Files

      Comment


      • #4
        Hi Camile.
        You didn't provide your Report and Report filter configs but it looks like you want to sum some value for the same entity 'Account Transaction' entity.
        1. You can set a filter condition for the Report. The condition should be based on the Enum field value.
        2. The formula entity\sumRelated works only for the related entities. If you don't have it then it won't work.
        3. FILTER is a name of a filter pre-defined in the system, created with the Report feature, or developed through code by yourself. I doubt that 'Reccuring' is developed filter, so it won't work.
        In another example FILTER like 'reportFilter136sa78568sad7' looks correct.

        Comment


        • #5
          Hi Maximus ,

          Thank you, that helps for understanding the filter.

          My report is all account transactions with a value that is Recurring (shown in the first screenshot attached). I've also attached a screenshot of the Report filter using this report.

          Have I not filtered my report correctly? My second workflow using this report filter doesn't account for only values that are recurring.
          Attached Files

          Comment


          • #6
            Ok, then let's create your own filter:
            1.Create a file /custom/Espo/Custom/SelectManagers/AccountTransaction.php with this code:
            PHP Code:
            <?php
            namespace Espo\Custom\SelectManagers;

            class 
            AccountTransaction extends \Espo\Core\SelectManagers\Base
            {
                protected function 
            filterRecurring(&$result)
                {
                    
            $result['whereClause'][] = [
                        
            'basis' => 'Recurring',
                    ];
                }
            }
            2. Set this formula to the Workflow
            Code:
            liARR = record\count('AccountTransaction', 'recurring');
            Note. Please check that your Account Transaction entity files are genuinely represented with the 'AccountTransaction' name.
            Last edited by Maximus; 03-18-2021, 01:45 PM.

            Comment

            Working...
            X