Some background. I’m trying to create another calculated field on a deal that shows the deal amount in a 3rd currency. The use case is that our South African sales teams sometimes sell a deal in CAD, but we still need this to show against a targeted ZAR amount. Our company currency is USD, so the deal already shows in CAD and USD.
Via the API, I’ve looked at the properties of the field “amount_in_home_currency” to see if I can use that calculation as a starting point. It is this:
“if is_present(string(deal_currency_code)) then if bool(hs_is_closed) then (amount * dated_exchange_rate(string(deal_currency_code), if is_present(string(closedate)) then string(closedate) else timestamp(hs_is_closed))) else (amount * exchange_rate(string(deal_currency_code))) else amount”
However, when I add that as the calculation for a new field via the API, I get an error:
“Unable to parse calculation formula in line 1 and column 133 - line 1, column 133:\nnot, -, round_down, round_up, round_nearest, is_present, number_to_string, string_to_number, concatenate, max, min, contains, date, time_between, begins_with, to_lower_case, to_upper_case, has_email_reply, has_plain_text_email_reply, extract_most_recent_email_reply_html, extract_most_recent_email_reply_text, extract_most_recent_plain_text_reply, pipeline_probability, month, year, period_to_months, dated_exchange_rate, currency_decimal_places, exchange_rate, set_contains_string, is_engagement_type, fetch_single_currency_portal_currency, format_full_name, (, NOW, DECIMAL, scientific number literal, string literal, true, false, IDENTIFIER, bool, string or timestamp expected, if encountered.”
I’ve managed to get my formula working by moving the nested ‘ifs’ up a level, but the issue for me is why the formula works for a HubSpot field, but doesn’t work for me? Does the API have more stringent validation?