May 7, 2014

Code to open a display menuitem


MyTable     myTable;

    Args           args;

    MenuFunction    menuFunction;

    ;

    myTable  =  CurrentTableBuffer;

    args = new Args();

    args.caller(element);

    new MenuFunction(menuitemdisplaystr(MenuItemNameOfTheFormWhich   HaveToOpen),MenuItemType::Display);

    menuFunction.run(args);

    super();

Opening a project in AX through the code

static void projectNodeOpen(Args _args)
{ 
    ProjectNode projectType,projectNode;
    ;
    projectType    =  Infolog.projectRootNode().AOTfindChild('Private');
    projectNode   =  projectType.AOTfindChild('EPTest');
    if (projectNode)
    {
        projectNode.getRunNode();
    }
}

May 6, 2014

Turn off/on Synchronize database when making changes to AOT tables


How to turn off/on Synchronize database when making changes to AOT tables.

Static void ShowSysSqlSync (Args _args)

{

    SysGlobalCache  sgc;
    str owner = 'SysSqlSync';
    str key   = 'ShowSysSqlSync';

     ;

    sgc = appl.globalCache();

    sgc.set(owner, key, true/false);

    Info (strfmt (' SqlSync  status : %1', sgc.get (owner, key)));

}

May 5, 2014

"continue" and "break" statements in X++



// Sample job using "continue" and "break" statements in X++
Static void sampleContinueBreak()
{
  int counter;
  
for (counter=1;counter <= 10;counter++)

  {           
     if (counter > 3 && counter < 8)

     {
       continue;

     }
     else if(counter == 9)

     {
        break;

     }
     info(int2str( counter));


  }
 
 info(int2str( counter));
   
}


//One more example

static int sampleSwitch(int x = 5)
{
 ; 

 switch (x)
 { 

  case (1):
  x = 5;

  case (5):
  x = x + 5;

  case (10):
  x = x + 10;
  break;

  case (20):
  x = x + 20;
  break;

  default:
  x = 5;


 }
info(strfmt("Return value is %1", x));
return x;

}