IfElse Formula to Calculate Percentage

Hello, 

I'm trying to create an ifelse function that calculates a different percentage of the Contract Price based on the State.

I tried the following, but am receiving an error of "Cannot read property 'returnType' of undefined"

 

ifElse(equal($estate_state_c),"QLD"),multiply(0.25,$contract_price_c),

ifElse(equal($estate_state_c),"NSW"),multiply(0.35,$contract_price_c),

ifElse(equal($estate_state_c),"VIC"),multiply(0.35,$contract_price_c)))

Can someone point out what I am doing wrong?

Thanks in advance!

Parents
  • 2 bugs:

    1) too much parenthesis, equal($estate_state_c) not really makes sense, but I suppose that's a copy/paste bug.

    2) the else-else-else part is missing, when estate_state is not QLD, NSQ or VIC, you need a return value and that is empty in your formula but must be of type currency.

    So try this formula:

    ifElse(equal($estate_state_c,"QLD"),multiply(0.25,$contract_price_c),
    ifElse(equal($estate_state_c,"NSW"),multiply(0.35,$contract_price_c),
    ifElse(equal($estate_state_c,"VIC"),multiply(0.35,$contract_price_c),0)))

    Harald Kuske
    Principal Solution Architect – Professional Services, EMEA
    hkuske@sugarcrm.com
    SugarCRM Deutschland GmbH

  • As you were so helpful previously, I was hoping you may be able to assist with an error I'm getting to a similar formula where I need a date to return.  The error is Invalid Formula: The formula must be of typedate.

    Below is the what I have so far:

    ifElse(equal($marketing_house_type_c,"Single Level Residential Dwelling"),addDays($build_stage_forecast_enclose_c,14),
    ifElse(equal($marketing_house_type_c,"Single Level Dual Key Dwelling"),addDays($build_stage_forecast_enclose_c,21),
    ifElse(equal($marketing_house_type_c,"Double Storey Residential Dwelling"),addDays($build_stage_forecast_enclose_c,14),0)))

  • Hi Cheryl, I believe the issue is that your very last argument, the number 0, is the value returned when all the other if conditions are not met. Since you need a date returned, I believe what you want is $build_stage_forecast_enclose_c + 0, or in other words, just $build_stage_forecast_enclose_c.

    Does that resolve the error?

    -Brenda

Reply Children
No Data