Tuesday, March 12, 2019

Clear cache with code X++ Dynamics 365/AX 2012

Code below can be used to clear caches for Dynamics 365 for Operations as well as AX 2012.

In AX 2012, copy and past code below into Job to execute and clear cache.

In D365 create runnable class as below, set that class as startup object for the project, set that project as startup project for the solution and execute class.

class RunnableClassTest
{       
    /// <summary>
    /// Runs the class with the specified arguments.
    /// </summary>
    /// <param name = "_args">The specified arguments.</param>
    public static void main(Args _args)
    {
        xSession::removeAOC();
        SysTreeNode::refreshAll();
        SysFlushDictionary::main(null);
        SysFlushAOD::main(null);
        SysFlushData::main(null);
        //SysBPCheckAIFDataObject::flushCache(true); // only for AX 2012
        SysFlushReportServer::main(null);
        SysFlushSystemSequence::main(null);
        xSession::updateAOC();
        info("Executed.");
    }

}

No comments:

Post a Comment

Happening

Upgrade from AX 2012 to Latest Dynamics 365 Finance and Operation

Below are the steps defined by sequence. 1. Create new Upgrade project in Dynamics LCS. 2. Create VSTS Project and connect it with L...

Trending now