I have an exchange_rate value stored in a super_user table. The user can adjust that value and then go to the stock_list form, where they should see prices in two currencies.
The exchange rate is used to calculate the value in the second currency: (other_currency_value = retail_price * exchange_rate).
However, changes made to the exchange_rate in the super_user form don’t get transfered through to the stock_list form, when I just switch between the two forms (from super_user to stock_list). They do appear in the form, if I restart Servoy Developer, but I need them to appear as soon as I switch to the stock_list form.
I am using an unstored calculation to work out the value in the other currency. The code for that calculation is as follows:
var other_currency_value = 0;
if (stock_to_superuser.exchange_rate > 0)
{
other_currency_value = retail_price_inc_vat * stock_to_superuser.exchange_rate;
}
return other_currency_value;
I am also using a method in my stock_list form named recalculate_field(), which is run from the onShow slot. That method is used to recalculate the value in the other_currency_value column. The code from this method is as follows:
databaseManager.saveData();
if (foundset.getSize() > 0)
{
databaseManager.recalculate(foundset);
}
I have also tried using other code in various ways to rectify this problem, but have had no joy with it.
I get the following error message when the stock form loads:
Exception executing calculation: calculated_stock_info of table stock, error: TypeError: Cannot convert null to an object. (recalculate_field; line 6)
java.lang.RuntimeException: Exception executing calculation: calculated_stock_info of table stock, error: TypeError: Cannot convert null to an object. (recalculate_field; line 6)
TypeError: Cannot convert null to an object. (recalculate_field; line 6)
Therefore can anyone out there tell me where I am going wrong with this approach. Any help would be greatly appreciated.
Craig