Notifications
Announcements
No record found.
Can the
Refresh Dictionary
Refresh Data
Refresh Elements
Be done in an x++ job?
*This post is locked for comments
Yes - they're just menu items.
static void mcaClearCaches(Args _args)
{// mca jeb 27Sep2013
Args args;
args = new args();
args.name(identifierStr(SysFlushAOD));
new MenuFunction(menuitemActionStr(SysFlushAOD), MenuItemType::Action).run(args);
args.name(identifierStr(SysFlushData));
new MenuFunction(menuitemActionStr(SysFlushData), MenuItemType::Action).run(args);
info(strFmt("Flushed data"));
args.name(identifierStr(SysFlushDictionary));
new MenuFunction(menuitemActionStr(SysFlushDictionary), MenuItemType::Action).run(args);
}
Janet
Be careful which tier (client/server) you are calling those SysFlush methods on. They work differently depending on the tier, and despite documentation to the contrary the flush does not always get communicated to other AOS (in a cluster, for example).
Running SysFlush on the client tier is basically the same as closing and re-opening the client, and will not solve issues related to a stale server cache. It also does not delete the AUC files, but there are other methods that do purge the AUC files in real time.
Great points; thanks, Brandon!
Another option would be to call the SysFlushXXX classes directly.
// adding "client" or "server" to the static method declaration to force where the refresh runs
public static void FlushAll()
{
// Leave the "args" as null will skip the info messages normally shown when using menu items.
SysFlushAOD::main(args);
SysFlushData::main(args);
SysFlushDictionary::main(args);
So, when you click the actual menu items, where do they run? Server or Client?
It depends, since it's "called from". Throw an info log on there if you want to tinker and see:
info(strfmt("Running on server? %1", Global::isRunningOnServer()));
When you click the menu items from the Tools->Caches menu from the client interface, they run on the client. This tends to be pretty pointless, since you can just as easily close and re-open the client. Where you really NEED to clear caches is on the server, especially in a cluster environment where changes made on one AOS may not be seen on the other until midnight when all AOS flush their cache on schedule. In my environments those menu items are set to Server and we use them frequently to avoid having a mass AOS restart when making parameter and changes to records in tables that are cached Entire table.
Hi Lee,
Regarding your below solution. May I know how to add "Client" or "Server" to the static method declaration to force where the refresh runs.
Also, what these commands do. Just they clear the cache ???
regards
~~~~
It is fine to execute from the AOT Menu, the action is different from running the job executing "main(args)". Brandon covered the explanation.
It is OK to test this Job in a DEV standalone box for understanding and educational purpose. There is a mixture of calls that hits both server and client when you execute the job. Copy the above code for testing as Alex suggested into all the system classes methods and it will tell you with the Infolog msg. Don't forget to remove the code later-on.
But never run the job particularly in High Availability/Clustered environments.
SysFlushAOD::main(args); // Avoid calling this main method directly in Multi-AOS environments.
SysFlushDictionary::main(args); // Refreshes few elements which are (enumeration types, EDT, classes, tables, configuration keys, license codes & security keys).
We have seen adverse effects in the past while one of our colleague introduced this job in Prod and executed it while other users accessing the instance faced nasty temp errors. This was probably 3 yrs ago.
I proved that it was causing harm and forced them remove that code and reboot AOS to recover from errors, Since it cleared Server side Cache while client AX32.exe has no idea as the references were still pointing to records cached on Server side.
Hope the explanation helps.
Here is a better job that should clear both the client and server caches:
static void AKWRefreshCaches(Args _args) { void runClientServer(str _actionMenuStr) { MenuFunction mf; mf = new MenuFunction(_actionMenuStr, MenuItemType::Action); mf.run(); mf = new MenuFunction(_actionMenuStr, MenuItemType::Action); mf.runOn(ClassRunMode::Server); mf.run(); } runClientServer(menuitemActionStr(SysFlushAOD)); runClientServer(menuitemActionStr(SysFlushData)); runClientServer(menuitemActionStr(SysFlushDictionary)); runClientServer(menuitemActionStr(SysFlushReportServer)); info("Done"); }
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Martin Dráb 4 Most Valuable Professional
Priya_K 4
MyDynamicsNAV 2