RSS

Tag Archives: cache

Effective way to resolve all weird issues caused by users’ cache

I found these steps below are very effective to clear up weird issues after code/data migration or when users start experiencing wacky behaviors

STEP 1: Run the job below

public server static void FlushAll(Args _args)
{
   Args args;
  
   // 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);

}

STEP 2: Delete user cache

Method 1:

  1. STOP AOS
  2. Log on to TS where all users use to connect to AX
  3. Search of *.AUC files and delete all these files
  4. Restart AOS

Method 2:

  1. Run this job on TS where all users use to connect to AX.
static void ClearAucFileForUsers(Args _args)
{
    System.Array    files;
    int             fileCount;
    int             i;
    str             nextFile;
    str             path = "C:\\Users";
    str             Finalpath;
    str             pattern = "*.auc";
    container       listOfFiles;
    int             DirCount;
   
   
    System.Array    Directories;
    int             j;
    str             nextDir;
    container       listOfDir;
   
    FileIOPermission    dirPermission, filePermission;
    InteropPermission   interopPermission;
    Set                 permissionSet;
   
    new InteropPermission(InteropKind::ClrInterop).assert();
    listOfDir = conNull();
    listOfFiles     = connull();
   
    Directories = System.IO.Directory::GetDirectories(path);
    if(Directories)
    {
        DirCount = Directories.get_Length();
       
        for(j=0; j < DirCount; j++)
        {
            nextDir    = Directories.GetValue(j);
            Finalpath = nextDir + "\\AppData\\Local";
            listOfDir += Finalpath;
        }       
    }
    j=0;
    DirCount = conLen(listOfDir);
    while( j < conLen(listOfDir))
    {
        j++;
        Finalpath = conPeek(listOfDir,j);
        try           
        {
            files           = System.IO.Directory::GetFiles(Finalpath, pattern);
        }
        catch
        {
            continue;   
        }
        if (files)
        {
            fileCount =    files.get_Length();
           
            for(i=0; i < fileCount; i++)
            {
                nextFile    = files.GetValue(i);
                System.IO.File::Delete(nextFile);       
                info(nextFile);
            }
        }
    }
   
    CodeAccessPermission::revertAssert();
}
  1. Stop and Restart AOS

STEP 3: Delete SysLastValue

static void DeleteAllLastValue(Args _args)
{
    SysLastValue syslastValue;   
   
     ttsBegin;
     delete_from syslastValue;
     ttsCommit;   
}
 
 

Tags: , , , , ,

How to flush AOS cache form code

Flush the AOS cache from code

Under Menu items > Action, duplicate all these 3 menu item actions and three menu action items that can be used to flush system data, the AOD, and dictionary
1. SysFlushAOD
2. SysFlushData
3. SysFlushDictionary

Duplicate these 3 menu action items and give them a new name

image

These three are running on “Called From” which when we run it on client side, it will clear client cache. We need to be able to clear AOD, sys data and dictionary and cause a refresh, therefore, we need to change it to “Server”

Go to RunOn property and change it from “Run-On” to “Server”

image

Now, start run each menu action item one by one.

static void DevClearCache(Args _args)
{
#define.FlushAOD(“DevSysFlushAOD”)                  // replace with your own menuitem name
#define.FlushData(“DevSysFlushData”)                // replace with your own menuitem name
#define.FlushDictionary(“DevSysFlushDictionary”)    // replace with your own menuitem name
Args args = new Args();
MenuFunction mf;

// Flush AOD
mf = new MenuFunction(menuitemActionStr(#FlushAOD), MenuItemType::Action);
mf.run(args);

// Flush Data
mf = new MenuFunction(menuitemActionStr(#FlushData), MenuItemType::Action);
mf.run(args);
info(“Data has been refreshed”);

// Flush Dictionary
mf = new MenuFunction(menuitemActionStr(#FlushDictionary), MenuItemType::Action);
mf.run(args);
}

You can download the entire project here.

 
2 Comments

Posted by on December 11, 2013 in Development

 

Tags: , , , , , ,

 
%d bloggers like this: