Refresh Account Profile Data

Brief

The article teaches how to refresh an account's profile data.

Details

How to Refresh Profiles of Account

in this article, you will learn how to use the FCLite API to refresh profiles of an account.
The idea behind this functionality is that when some settings are changed on the server, it sends a flag to the client indicating what data needs to be refreshed.

To get the refresh profile flags of an account, you can use the getRefreshProfileFlags method.
This method returns a set of values that define which managers in FCLite need to execute the refresh() method to download the updated data from the server.

Below, is an example that shows how to process refresh profile flags:

Create instance of the instruments manager Hide

typescriptjavascript
public static processAccountRefreshProfileFlags(account: FXConnectLite.Account): void { let refreshProfileFlags = account.getRefreshProfileFlags(); if (refreshProfileFlags) { Printer.print(`{RefreshProfileFlags is ${refreshProfileFlags}`) const aFlags = Array.from(refreshProfileFlags); aFlags.forEach(function (flag) { switch(flag ) { case 'A': case 'a': case 'B': case 'b': case 'P': Printer.print(`AccountCommissionsManager refresh`) Application.session.getAccountCommissionsManager().refresh(); break; case 'L': case 'l': case 'M': case 'm': Printer.print(`LeverageProfilesManager refresh`) Application.session.getLeverageProfilesManager().refresh(); break; case 'R': case 'r': case 'Y': Printer.print(`RolloverProfilesManager refresh`) Application.session.getRolloverProfilesManager().refresh(); break; case 'X': Printer.print(`AccountCommissionsManager LeverageProfilesManager refresh`) Application.session.getAccountCommissionsManager().refresh(); Application.session.getLeverageProfilesManager().refresh(); break; } }); } else { Printer.print(`RefreshProfileFlags is empty`) } }

In this example, we first get the refresh profile flags of an account using the getRefreshProfileFlags method.
Then, we iterate over each flag and use a switch statement to determine which manager needs to execute the refresh() method.
For example, if the flag is 'A', 'a', 'B', 'b', or 'P', we call the refresh() method on the AccountCommissionsManager.
This will download the updated data from the server for that manager.

Conclusion:
You have learned how to use the FCLite API to refresh profiles of an account. When some settings are changed on the server, it sends a flag to the client indicating what data needs to be refreshed. You can use the getRefreshProfileFlags method to get the refresh profile flags of an account, which define which managers in FCLite need to execute the refresh() method to download the updated data from the server. By following the example provided, you can learn how to process refresh profile flags and ensure that your data is up-to-date.

Download the sample TypeScript, JavaScript.

back