Thursday, April 5, 2018

SysDictClass object not initialized (Global Cache problem)

I found the case SysDictClass object not initialized as it should be when I was testing creating and posting Sales confirmation last week. After waste almost a day on the debugging (including trying standard menu clear cache, redeploy, clear usage, generate CIL, compile AOT and etc.)  

Finally, I found the reason is the global cache.





Before mention about the solution, let me memorize the clue or the scenario which might relate to the cache problem. The possible signals of the problems are:

  • The report is printed to screen (PDF format) successfully, but come up with an info windows tells us the report is printed to screen. (In normal situation, there is no such a message. In my case, object of class SalesFormLetterConfirmContract does NOT instantiated correctly, so the SSRS framework printed that report by an alternative way.)
  • Object which runs on client doesn’t get the initial value or get strange value instead, once initialize.
    • SalesFormLetter::mainOnServer (\Classes\SalesFormLetter line 92)  return normal value
    • SalesFromLetter::contruct (\Classes\SalesFormLetter line 95)           return disappear value
  • Some round of testing, you might get the correct value! (Data integrity issue situation)
  • Strange behavior for example inconsistent data on ax session, debugger, breakpoint memorize and so on.


Solution
From google, I found these two jobs are very useful.


-------------------------------------------------------------------------------
static void RefreshLocalCache(Args _args)
{
xSession::removeAOC();
SysTreeNode::refreshAll();
SysFlushDictionary::main(null);
SysFlushAOD::main(null);
SysFlushData::main(null);
SysBPCheckAIFDataObject::flushCache(true);
SysFlushReportServer::main(null);
SysFlushSystemSequence::main(null);
xSession::updateAOC();
info(“ok”);
}


Ref: https://gfeaxblog.wordpress.com/2017/12/14/ax-2012-clear-the-cache/
-------------------------------------------------------------------------------


-------------------------------------------------------------------------------
static void ResetAUC(Args _args)
{
#AiF
SysSQMSettings _Settings;
;
ttsbegin;
update_recordset _Settings setting GlobalGUID = str2Guid(#EmptyGuidString);
ttscommit;
info("Now we have to Restart the AOS Service to use a new GlobalGUID.");
}

So next time, you find these kind of situation, try to check your cache also! Until the next post!