Currency conversion macro sample doesn't work with new version

Hello,

I want to make a macro inspired by the Currency conversion sample (Currency conversion | ONLYOFFICE).
So i tried it but it doesn’t work with the new 9.3.1.8 version (with an older one, it worked but i don’t remember which version it was. Maybe 9.2.XX)
The macro throw an error in the reloadCellValues function (Api.asc_calculate is not a function).

Can anyone help me?

Thank you.

OS version: Linux Ubuntu 25.04
App version: 9.3.1.8
Downloaded from: .deb from the site and install as recommended
Additional information:
In the devtools console we can see the error…

Hello, thank you for your report and for the details you have already shared!
We are already checking this behavior on our side.
​To help us localize the issue more precisely, please also send us the exact macro code you wrote and are currently testing. This will help us compare your real scenario with the official sample and investigate the problem faster.
Best regards.

Hello,

It’s almost exactly the same code :

(function () {

  function buildURL(baseCurrency, currencies) {
    const currencyParam = currencies.join("%2C");
    return `https://api.coingecko.com/api/v3/simple/price?ids=${currencyParam}&vs_currencies=${baseCurrency}`;
  }

  function reloadCellValues() {
    setTimeout(function () {
      Api.asc_calculate(Asc.c_oAscCalculateType.All);
    }, 5000);
  }

  function fetchAndPopulateData(url, currencies) {
    const xhr = new XMLHttpRequest();
    xhr.open("GET", url, true);

    xhr.onload = function () {
      if (this.status === 200) {
        const apiData = JSON.parse(this.response);
        const sheet = Api.GetSheet("Cours");
       
        currencies.forEach((currency, index) => {
          if (apiData[currency][baseCurrency]) {
            sheet.GetRange(`A${index + 3}`).SetValue(currency);
            sheet.GetRange(`B${index + 3}`).SetValue(apiData[currency][baseCurrency]);
          } else {
            console.warn(`Currency ${currency} not found in the response.`);
          }
        });
      } else {
        console.error(`Error fetching data: ${this.statusText}`);
      }
    };

    xhr.onerror = function () {
      console.error(
        "There was some error in your request. Check and try again."
      );
    };

    xhr.send();
  }

  const baseCurrency = "eur";
  const currencies = ["bitcoin", "ethereum", "binancecoin"];
  const latestURL = buildURL(baseCurrency, currencies);
  fetchAndPopulateData(latestURL, currencies);
  reloadCellValues();

})();

In the meantime i rollback to the old version (9.2.0.100) and it work’s fine.

Thank you in advance for you help.

Best regards.

Hello @nclement !
Thank you for your report and for sharing the macro code!
We have checked the situation: undocumented methods are no longer available for use in macros, so Api.asc_calculate(…) should not be used in this scenario.

Please use the documented method Api.RecalculateAllFormulas() instead. ​
Please try this method and let us know whether everything works correctly in your case.

The current macro sample page will be corrected as well.

Best regards!

Hello,

Thank you for your help and sorry for the delay.

With RecalculateAllFormulas i don’t have the error anymore.
But now, i have to refresh the sheet by pressing F9 to see the updated data.
They do not recharge automatically. Maybe because i don’t use formulas, juste simple additions, multiplications…

Best regards.

Hello, @nclement !
Thank you for the detailed checks and the update.

To reproduce your case as accurately as possible, could you please send:

  1. The exact macro code that you are currently using (the full script).
  2. The spreadsheet file where this macro is executed and where you see that values are updated only after pressing F9.

Once we have your macro code and a sample file, we will reproduce the scenario on our side and check what is causing the need for manual recalculation.