rollupConditionalSum and multiple conditions

Hi,

I have created two custom modules which we feed data into from our on-prem systems via the Sugar API.
Obviously rollupConditionalSum only allows one condition, but I need 2 conditions for the calculation I want

I found an article explaining new functions can be created by using a custom php file.
We are using the hosted version of Sugar so I have no idea if I can access the file system to create a new php file?

Cut-down table structure below:

ad_admin_details
id
FeesBilled = rollupConditionalSum($ad_admin_details_ad_transaction_details,"amount_c","category_c","Fees Billed")
FeesBilledInLast2Years = ?????? category_c = 'Fees Billed' AND transDate_c > NOW() - INTERVAL 2 YEAR

ad_transaction_details
id
AdminDetailsId_c
transdate_c
category_c
amount_c

We are currently on Sugar 10.1

Thanks,
Angus

Parents
  • Hi  ,

    Introducing a new Sugar Logic function is unnecessary here and also would not directly solve your requirements for the issue. Sugar Logic formulas are recalculated on saving a record, so for a dynamic requirement of 'was this event within the past 2 years?', you would have to resave all the records each day to perform that evaluation. 

    Our Upsert Calculated Fields plugin was design to address this use case so that you can use Sugar Logic evaluations in a dynamic fashion to get accurate reporting.

    As for the rollupConditionalSum formula, there is no need to change anything with that formula. When you have multiple conditions you want to perform a rollup calculation on, my recommended practice is to create a new field in the child module that performs that evaluation. For your example, your ad_transaction_details module would have a field created that looks like the following:

    ifElse(
        and(
            isInList(
                $category_c,
                createList(
                    "Fees Billed"
                )
            ),
            greaterThan(
                daysUntil(
                    $transdate_c
                ),
                -731
            )
        ),
        "2-Year Billing",
        ""
    )

    Then, your rollupConditionalSum formula would be based on that new field where the value is "2-Year Billing".

    Lastly, you mention you are using a hosted version of Sugar. If you are hosted by Sugar, you should be on version 14.1 or 14.2. 10.1 is over 4 years old and well outside Sugar's supported release cycle. As long as you are on a supported release, our plugin will work. If you are on 10.1 and hosted by someone other than Sugar, a custom-developed solution may be your best option if upgrading to a supported release is not feasible in the near future.

    Chris

Reply
  • Hi  ,

    Introducing a new Sugar Logic function is unnecessary here and also would not directly solve your requirements for the issue. Sugar Logic formulas are recalculated on saving a record, so for a dynamic requirement of 'was this event within the past 2 years?', you would have to resave all the records each day to perform that evaluation. 

    Our Upsert Calculated Fields plugin was design to address this use case so that you can use Sugar Logic evaluations in a dynamic fashion to get accurate reporting.

    As for the rollupConditionalSum formula, there is no need to change anything with that formula. When you have multiple conditions you want to perform a rollup calculation on, my recommended practice is to create a new field in the child module that performs that evaluation. For your example, your ad_transaction_details module would have a field created that looks like the following:

    ifElse(
        and(
            isInList(
                $category_c,
                createList(
                    "Fees Billed"
                )
            ),
            greaterThan(
                daysUntil(
                    $transdate_c
                ),
                -731
            )
        ),
        "2-Year Billing",
        ""
    )

    Then, your rollupConditionalSum formula would be based on that new field where the value is "2-Year Billing".

    Lastly, you mention you are using a hosted version of Sugar. If you are hosted by Sugar, you should be on version 14.1 or 14.2. 10.1 is over 4 years old and well outside Sugar's supported release cycle. As long as you are on a supported release, our plugin will work. If you are on 10.1 and hosted by someone other than Sugar, a custom-developed solution may be your best option if upgrading to a supported release is not feasible in the near future.

    Chris

Children
No Data