Thursday, April 7, 2016

MB6-890 Microsoft Development Introduction - AX7 (Rainer) - Exam Topics

Exam Topics
Understand the Architecture and Development Environment (20% - 25%)
Understand the Architecture and Development Environment
This objective may include but is not limited to: identify features of Microsoft Dynamics AX; describe the development environment; describe the components in the application stack; identify cloud architecture components; explain the server architecture; describe the layer architecture.
Use Microsoft Visual Studio to manage development with Microsoft Dynamics AX
This objective may include but is not limited to: identify the windows and basic navigation of Visual Studio; describe differences between and uses for projects, models, solutions, and packages.

Use the Application Explorer to Develop New Elements (25% - 30%)
Create and manage labels and resources
This objective may include but is not limited to: create new label files; create and use labels; describe elements and uses for labels; identify best practices for labels identify uses for resources.
Create and manage data types
This objective may include but is not limited to: describe uses for base enumerations; create new base enumerations; identify best practices for base enumerations; describe primitive and extended data types; create new extended data types; identify key properties for extended data types; implement best practices for extended data types.
Create and manage tables
This objective may include but is not limited to: identify the components of a table; describe various types of table relationships; describe various types of table indexes; implement best practices for tables, relationships, and indexes.
                                                        
Read, Write and Understand Basic X++ (30% - 35%)
Describe X++
This objective may include but is not limited to: identify the characteristics of X++; use the code editor to write X++; describe the features of IntelliSense; identify basic syntax for X++; describe the use of common key words in X++; describe the features of the debugger; use the comparison tool; use the best practice checker.
Work with X++ control statements
This objective may include but is not limited to: work with variables, operators, conditional statements, and loops; use built-in functions; use communication tools.
Work with classes
This objective may include but is not limited to: create new classes; describe scoping events and parameters; describe inheritance; identify key best practices when writing X++.
Use X++ to manipulate data
This objective may include but is not limited to: identify techniques for data retrieval; explain uses for transaction integrity checking; insert, update, and delete records using X++; identify best practices for manipulating data with X++.
Manage exceptions in X++
This objective may include but is not limited to: identify exception types; use try/catch statements; describe the features of optimistic concurrency control; describe best practices for exception handling with X++ .

Manage the User Interface and Security for Developers  (20% - 25%)
Manage the user interface
This objective may include but is not limited to: identify components of various form patterns; identify common form patterns and sub patterns; identify key properties for form elements; apply and validate form patterns; describe uses for tiles; describe how to join data in forms; implement best practices for form development.
Manage user navigation
This objective may include but is not limited to: identify types of menu items; create menu items and menus; identify key properties for menu items; describe uses for menu items; implement best practices for menus and menu items.
Manage security in the development environment
This objective may include but is not limited to: describe the security architecture; describe the components of role-based security; create new privileges, duties, and roles in the application explorer; describe the extensible data security framework.

Tuesday, October 13, 2015

AX DB Restore Scripts - Moving AX DB from one server to another server

Following SQL script is very useful while moving AX DB from one server to other server. Thanks to http://www.exploreax.com.

Declare @AOS varchar(30) = '[AOSID]' --must be in the format '01@SEVERNAME'
---Reporting Services---
Declare @REPORTINSTANCE varchar(50) = 'AX'
Declare @REPORTMANAGERURL varchar(100) = 'http://[DESTINATIONSERVERNAME]/Reports_AX'
Declare @REPORTSERVERURL varchar(100) = 'http://[DESTINATIONSERVERNAME]/ReportServer_AX'
Declare @REPORTCONFIGURATIONID varchar(100) = '[UNIQUECONFIGID]'
Declare @REPORTSERVERID varchar(15) = '[DESTINATIONSERVERNAME]'
Declare @REPORTFOLDER varchar(20) = 'DynamicsAX'
Declare @REPORTDESCRIPTION varchar(30) = 'Dev SSRS';

---SSAS Services---
Declare @SSASSERVERNAME varchar(20) = '[YOURSERVERNAME]\AX'
Declare @SSASDESCRIPTION varchar(30) = 'Dev SSAS'; -- Description of the server configuration

---BC Proxy Details ---
Declare @BCPSID varchar(50) = '[BCPROXY_SID]'
Declare @BCPDOMAIN varchar(50) = '[yourdomain]'
Declare @BCPALIAS varchar(50) = '[bcproxyalias]'
---Service Accounts ---
Declare @WFEXECUTIONACCOUNT varchar(20) = 'wfexc'
Declare @PROJSYNCACCOUNT varchar(20) = 'syncex'
---Help Server URL---
Declare @helpserver varchar(200) = 'http://[YOURSERVER]/DynamicsAX6HelpServer/HelpService.svc'

---Outgoing Email Settings---
Declare @SMTP_SERVER varchar(100) = 'smtp.mydomain.com' --Your SMTP Server
Declare @SMTP_PORT int = 25
---DMF Folder Settings ---
Declare @DMFFolder varchar(100) = '\\[YOUR FILE SERVER]\AX import\ '

---Email Template Settings---
Declare @EMAIL_TEMPLATE_NAME varchar(50) = 'Dynamics AX Workflow QA - TESTING'
Declare @EMAIL_TEMPLATE_ADDRESS varchar(50) = 'workflowqa@mydomain.com'
---Email Address Clearing Settings---
DECLARE @ExclUserTable TABLE (id varchar(10))
insert into @ExclUserTable values ('userid1'), ('userid2')

--List of users separated by | to keep enabled, while disabling all others
Declare @ENABLE_USERS NVarchar(max) = '|Admin|TIM|'
--List of users separated by | to disable, while keeping all the rest enabled all others
--Declare @DISABLE_USERS NVarchar(max) = '|BOB|JANE|'

--*****BEGIN UPDATES*******---

---Update AOS Config---
delete from SYSSERVERCONFIG where RecId not in (select min(recId) from SYSSERVERCONFIG)
update SYSSERVERCONFIG set serverid=@AOS, ENABLEBATCH=1
where serverid != @AOS -- Optional if you want to see the "affected row count" after execution.

---Update Batch Servers---
delete from BATCHSERVERGROUP where RecId not in (select min(recId) from BATCHSERVERGROUP group by GROUPID)
update BATCHSERVERGROUP set SERVERID=@AOS
where serverid != @AOS -- Optional to see "affected row count"
update batchjob set batchjob.status=4 where batchjob.CAPTION = '[BATCHJOBNAME]'
update batch set batch.STATUS=4 from batch inner join BATCHJOB on BATCHJOBID=BATCHJOB.RECID AND batchjob.CAPTION = '[BATCHJOBNAME]'

---Update Reporting Services---
delete from SRSSERVERS where RecId not in (select min(recId) from SRSSERVERS)
update SRSSERVERS set
    SERVERID=@REPORTSERVERID,
    SERVERURL=@REPORTSERVERURL,
    AXAPTAREPORTFOLDER=@REPORTFOLDER,
    REPORTMANAGERURL=@REPORTMANAGERURL,
    SERVERINSTANCE=@REPORTINSTANCE,
    AOSID=@AOS,
    CONFIGURATIONID=@REPORTCONFIGURATIONID,
    DESCRIPTION=@REPORTDESCRIPTION
where SERVERID != @REPORTSERVERID -- Optional if you want to see the "affected row count" after execution.

---Update SSAS Services---
delete from BIAnalysisServer where RecId not in (select min(recId) from BIAnalysisServer)
update BIAnalysisServer set
    SERVERNAME=@SSASSERVERNAME,
    DESCRIPTION=@SSASDESCRIPTION,
ISDEFAULT = 1
WHERE SERVERNAME <> @SSASSERVERNAME -- Optional where clause if you want to see the "affected rows

---Set BCPRoxy Account---
update SYSBCPROXYUSERACCOUNT set SID=@BCPSID, NETWORKDOMAIN=@BCPDOMAIN, NETWORKALIAS= @BCPALIAS
where NETWORKALIAS != @BCPALIAS --optional to display affected rows.
---Set WF Execution Account---
update SYSWORKFLOWPARAMETERS set EXECUTIONUSERID=@WFEXECUTIONACCOUNT where EXECUTIONUSERID != @WFEXECUTIONACCOUNT
---Set Proj Sync Account---
update SYNCPARAMETERS set SYNCSERVICEUSER=@PROJSYNCACCOUNT where SyncServiceUser!= @PROJSYNCACCOUNT
---Set help server URL---
update SYSGLOBALCONFIGURATION set value=@helpserver where name='HelpServerLocation' and value != @helpserver

---Update Email Parameters---
Update SysEmailParameters set SMTPRELAYSERVERNAME = @SMTP_SERVER, @SMTP_PORT=@SMTP_PORT
---Update DMF Settings---
update DMFParameters set SHAREDFOLDERPATH = @DMFFolder
where SHAREDFOLDERPATH != @DMFFolder --Optional to see affected rows

---Set BCPRoxy Account---
update SYSBCPROXYUSERACCOUNT set SID=@BCPSID, NETWORKDOMAIN=@BCPDOMAIN, NETWORKALIAS= @BCPALIAS
where NETWORKALIAS != @BCPALIAS --optional to display affected rows.
---Set WF Execution Account---
update SYSWORKFLOWPARAMETERS set EXECUTIONUSERID=@WFEXECUTIONACCOUNT where EXECUTIONUSERID != @WFEXECUTIONACCOUNT
---Set Proj Sync Account---
update SYNCPARAMETERS set SYNCSERVICEUSER=@PROJSYNCACCOUNT where SyncServiceUser!= @PROJSYNCACCOUNT
---Set help server URL---
update SYSGLOBALCONFIGURATION set value=@helpserver where name='HelpServerLocation' and value != @helpserver

---Update Email Templates---
update SYSEMAILTABLE set SENDERADDR = @EMAIL_TEMPLATE_ADDRESS, SENDERNAME = @EMAIL_TEMPLATE_NAME where SENDERADDR!=@EMAIL_TEMPLATE_ADDRESS OR  SENDERNAME!=@EMAIL_TEMPLATE_NAME;
update SYSEMAILSYSTEMTABLE set SENDERADDR = @EMAIL_TEMPLATE_ADDRESS, SENDERNAME = @EMAIL_TEMPLATE_NAME where SENDERADDR!=@EMAIL_TEMPLATE_ADDRESS OR  SENDERNAME!=@EMAIL_TEMPLATE_NAME;
---Update User Email Addresses---
update sysuserinfo set sysuserinfo.EMAIL = '' where sysuserInfo.ID not in (select id from @ExclUserTable)

---Disable all users except for a specific set---
update userinfo set userinfo.enable=0 where  CharIndex('|'+ cast(ID as varchar) + '|' , @ENABLE_USERS) = 0
---Disable specific users---
---update userinfo set userinfo.enable=0 where  CharIndex('|'+ cast(ID as varchar) + '|' , @DISABLE_USERS) > 0

--Clean up server sessions
delete from SYSSERVERSESSIONS
--Clean up client sessions.
delete from SYSCLIENTSESSIONS

reference : http://www.exploreax.com/blog/blog/2015/10/13/ax-db-restore-scripts-full-script/

Wednesday, June 17, 2015

How to get Paper sizes in AX 2012

static void Job1(Args _args)
{
    System.Drawing.Printing.PrinterSettings printSetting = new System.Drawing.Printing.PrinterSettings();
    System.Drawing.Printing.PaperSize  size = new System.Drawing.Printing.PaperSize();
    System.Collections.ArrayList    paperSizes;
    System.Collections.IEnumerator  enumerator;

    paperSizes= printSetting.get_PaperSizes();
    enumerator = paperSizes.GetEnumerator();

    while (enumerator.MoveNext())
    {
        size = enumerator.get_Current();
        info(size.get_PaperName());   
    }

}

Thursday, May 14, 2015

How to delete Label Files from AX 2012

Here are the steps to delete Label Files from AX 2012:

  • Create a new model. You could call it "Test".
  • Open the AOT and move the Label File(s) you want to get rid of to the new model.
  • Close AX and stop the AOS.
  • Use AXUtil to delete the new model.
  • Select the label files (name start with 'ax' and followed with label id. select all files) and Delete from the server folder; C:\Program Files\Microsoft Dynamics AX\60\Server\...\bin\Application\Appl\Standard
  • Start the AOS.
  • Skip the upgrade wizard.

Friday, February 6, 2015

Read text file and SubStr to fetch fixed length columns - AX 2012

static void readTextFile(Args _args)
{
    Container               con;
    Filename                filename, Filename2;
    FileIOPermission        permission;
    TextIO                  textIO, textIO1;
    Str1260                 line;
    #File
    ;
    
    Filename = @"C:\Test\testFile.txt";
    permission = new fileIOpermission(filename,"RW");
    permission.assert();
    textIO = new TextIO(filename,#io_read);
    //textIO.inFieldDelimiter('|');
    if(textIO)
    {
        while(textIO.status() == IO_Status::Ok)
        {
            con = textIO.read();
            if(con)
            {
                line = Global::con2Str(con);
                info(strFmt("text - %1",line));
                info(strFmt("Company id - %1",subStr(line,1,4)));
                info(strFmt("code - %1",subStr(line,5,6)));
                info(strFmt("account num - %1",subStr(line,12,14)));
                info(strFmt("transdate - %1",subStr(line,26,6)));
                info(strFmt("Cheque num - %1",subStr(line,32,10)));
                info(strFmt("amount - %1",subStr(line,42,8)));
                break;
            }
        }
    }
}

Customer payment journal through X++ Code - AX 2012

static void cust_GLPosting(Args _args)
{
    Ledgerjournalname       ledgerjournalname;
    LedgerjournalTable      LedgerjournalTable;
    LedgerjournalTrans      LedgerjournalTrans;
    LedgerjournalCheckPost  LedgerjournalCheckPost;
    NumberSeq               numberSeq;
    Container               con;
    Filename                filename, Filename2;
    FileIOPermission        permission;
    TextIO                  textIO, textIO1;
    Dialog                  dialog;
    DialogField             dialogField;
    AccountNum              customerAccount= 'BRMF-000001';
    AccountNum              offsetAccNum = 'B01';
    #File

    select ledgerjournalname where ledgerjournalname.JournalName == "Test";
    ttsBegin;
    LedgerjournalTable.JournalName = ledgerjournalname.JournalName;
    LedgerjournalTable.initFromLedgerJournalName();
    LedgerjournalTable.JournalNum  = JournalTableData::newTable(LedgerjournalTable).nextJournalId();
    LedgerjournalTable.insert();
    ttsCommit;
        
    ttsBegin;
    numberSeq                               =   NumberSeq::newGetVoucherFromId((ledgerjournalname.NumberSequenceTable));
    LedgerjournalTrans.Voucher              =   numberSeq.voucher();
    LedgerjournalTrans.JournalNum           =   LedgerjournalTable.JournalNum;
    LedgerjournalTrans.CurrencyCode         =   "USD";
    LedgerjournalTrans.ExchRate             =   Currency::exchRate(LedgerjournalTrans.CurrencyCode);
    LedgerjournalTrans.AccountType          =   LedgerJournalACType::Cust;
    LedgerjournalTrans.parmAccount(customerAccount,LedgerjournalTrans.AccountType);
    LedgerjournalTrans.Txt                  =   'Testing';//conPeek(con,1);
    LedgerjournalTrans.AmountCurCredit      =   200;//conPeek(con,3);
    LedgerjournalTrans.TransDate            =   systemDateGet();//str2Date(conPeek(con,4),123);
    LedgerjournalTrans.OffsetAccountType    =   LedgerJournalACType::Bank;//LedgerjournalTable.OffsetAccountType;
    //LedgerJournalTrans.offsetacco
    LedgerjournalTrans.OffsetLedgerDimension =   22565431567; //LedgerjournalTable.OffsetLedgerDimension;
    LedgerjournalTrans.DefaultDimension     =   CustTable::find(customerAccount).DefaultDimension;
    LedgerjournalTrans.OffsetDefaultDimension=  CustTable::find(customerAccount).DefaultDimension;
    LedgerjournalTrans.insert();
    ttsCommit;
               
    LedgerjournalCheckPost = LedgerjournalCheckPost::newLedgerJournalTable(LedgerjournalTable,NoYes::Yes);
    LedgerjournalCheckPost.run();
    
}