I have been looking at auto-update a amount (home currency) field from another module. Zoho native multicurrency was used in the other module (we have 4 here). Custom script was input with no error, but the field was not updated on trigger. Script as below:
{
sourceRecord = zoho.crm.getRecordById("Price_List",recordId);
if(sourceRecord.get("Product") != null)
{
targetId = sourceRecord.get("Product").get("id");
chosenCurrency = sourceRecord.get("Currency");
foreignAmount = sourceRecord.get("USD").toDecimal();
exchangeRate = sourceRecord.get("Exchange_Rate").toDecimal();
homeAmount = 0.0;
if(exchangeRate > 0)
{
homeAmount = (foreignAmount / exchangeRate).round(2);
}
updateMap = Map();
updateMap.put("Subs_Price",homeAmount);
updateMap.put("Currency",chosenCurrency);
updateResponse = zoho.crm.updateRecord("Subscription",targetId,updateMap);
info "Selected Currency: " + chosenCurrency;
info "Active Exchange Rate: " + exchangeRate;
info "Calculated Home Amount: " + homeAmount;
info updateResponse;
}
}
What is wrong here?