Interview Questions

Thursday, October 22, 2015

5 Quick User Tips and Tricks for Dynamics AX 2012


Tip# 1: Save report queries for common report selections
Often a single report is run multiple different ways by a user. AX 2012 allows the user to save the report queries so the next time the report needs to be generated for a specific query the user can select the saved query rather than re-enter the tables, fields, and selection criteria.
* Note that this functionality is user specific and not a global change.
To save a report query, do the following:
From the report being generated, after clicking on the Select button and entering the selection criteria, click on the Modify button→ Save as:
Figure 1 - Save a report query
Figure 1 - Click on Modify→ Save as to save selection criteria
Give the report query a name then click OK.
Figure 2 - Give the report query a name
Figure 2 - Manually enter a name for the query then click OK
In the future when generating the report, even after running for different criteria, the user can retrieve the saved query. This can be done by clicking on the Select button then selecting the saved query from the Select query lookup.
Figure 3 - Select the saved query when the report is generated at a later time
Figure 3 - Select the saved query when the report is generated at a later time
The selected tables, fields and selection criteria will populate from the saved query:
Figure 4 - Criteria populates from selected saved query
Figure 4 - Criteria populates from selected saved query
Tip#2: Personalize the Status bar to add or remove fields
Figure 5 - Microsoft Dynamics AX 2012 Status bar
Figure 5 - Microsoft Dynamics AX 2012 Status bar
Go to File→ Tools→ Options
Figure 6 - File, Tools, Options
Figure 6 - File→ Tools→Options
Click on the Status bar link then mark the checkboxes for the fields to see on the Status bar.
* Note that the selections are user specific, not global changes.
Figure 7 - Status bar options
Figure 7 - Status bar options
Click on the Close button then view the Status bar for changes made.
Tip# 3: Perform simple math calculations (+, -, *, /) in a numeric fields in forms
In the screenshot below, “90+2000” has been entered in the journal line Credit field.
Figure 8 - Enter calculation in a numeric field
Figure 8 - Enter calculation in a numeric field
After tabbing out of the field, AX has performed the calculation and saved the value as 2,090:
Figure 9 - View the sum calculated after tabbing out of field
Figure 9 - View the sum calculated after tabbing out of field
Tip# 4: Use the Shortcut Ctrl + T to Export a form to Excel. That’s it for number 4!
Tip# 5: Use question marks (?) in filtering and querying fields to search for the exact amount of unknown characters.
In the below screenshot, seven question marks (???????) have been entered in the Customer account query field. AX searches for and returns all Customer accounts with exactly 7 characters.
Figure 10 - Example showing a query for exactly seven unknown characters
Figure 10 - Example showing a query for exactly seven unknown characters

Create CSV file through code in AX 2012 R3

static void Gulshan_TestCSV(Args _args)
{
CommaTextIo file; 
String30    CTN;
container line;
CustTable custTable;
#define.filename(@'C:\Test\ABC.csv')
#File
file = new CommaTextIo(#filename, #io_write);
if (!file || file.status() != IO_Status::Ok)
{
throw error("File cannot be opened.");
}
CTN = custTable.name();

while select AccountNum from custTable
{
line = [
custTable.Name() ,
custTable.Name()];
file.writeExp(line);
}
info(strFmt("File %1 created in specified folder.", #filename));
}

Import worker through Excel in AX 2012 R3

static void ImportWorkerthruExcel(Args _args)
{
    SysExcelApplication xlsApplication;
    SysExcelWorkBooks xlsWorkBookCollection;
    SysExcelWorkBook xlsWorkBook;
    SysExcelWorksheets xlsWorkSheetCollection;
    SysExcelWorksheet xlsWorkSheet;
    SysExcelRange xlsRange;
    SysExcelCells Cells;
    SysExcelCell RCell;
    CommaIO inFile;
    int nRow,i;
    DialogField dialogPath;
    Dialog dialog;
    Filename filename;
    Name firstName, LastName;
    LegalEntity LegalEntity;
    HcmPersonnelNumberId PersonnelNo;
    HcmEmploymentType WorkerType;
    HcmWorker hcmWorker;
    DirPerson dirPerson;
    DirPartyTable DirPartyTable;
    HcmEmployment HcmEmployment;
    DirPersonName DirPersonName;
    HcmPersonPrivateDetails HcmPersonPrivateDetails;
    HcmPersonIdentificationNumber HcmPersonIdentificationNumber;
   // importworker importworker;
    NameAlias SearchName;
    BirthDate   birthdate;
    str         CountryCode;
    str         IdentificationNumber;
    ExpirationDate  ExpireDate;



    DirAddressBookPartyAllView DirAddressBookPartyAllView;
    HcmPositionDuration HcmPositionDuration;
    ;
    dialog = new Dialog("Import");
    dialogPath = dialog.addField(extendedTypeStr(Filenameopen), "File Name");
    dialog.run();
    if (dialog.run())
    {
    filename = (dialogPath.value());
    }
    inFile = new CommaIO (filename, 'R');
    if (!inFile || infile.status() != IO_Status::Ok )
    {
    throw error (strfmt("@SYS19312",filename));
    }
    try
    {
    xlsApplication = SysExcelApplication::construct();
    xlsWorkBookCollection = xlsApplication.workbooks();
    xlsWorkBookCollection.open(filename);
    xlsWorkSheetCollection = xlsApplication.worksheets();
    xlsWorkSheet = xlsWorkSheetCollection.itemFromNum(1);
    Cells = xlsWorkSheet.Cells();
    nRow = 2;
    RCell = Cells.Item(nRow, 1);
    while (RCell.value().bstr() != "")
    {
    //Name = RCell.value().bStr();
    RCell = Cells.item(nRow,2);
    SearchName = RCell.value().bStr();
    //RCell = Cells.item(nRow,2);
    //PersonnelNo = RCell.value().bStr();
    RCell = Cells.item(nRow,3);
    FirstName = RCell.value().bStr();
    RCell = Cells.item(nRow,4);
    LastName = RCell.value().bStr();

    RCell = Cells.item(nRow,13);
    birthdate = str2DateDMY(RCell.value().bStr());

    RCell = Cells.item(nRow,5);
    CountryCode = RCell.value().bStr();


    DirPerson.Name = firstname+" "+LastName;

    dirpersonname.FirstName =  firstname;
    dirpersonname.LastName  = LastName;
    dirperson.NameAlias = SearchName;
    // LogisticsElectronicAddress.Locator =  Telephone;
    //hcmWorker.Person=dirPerson.RecId;
    //exportImportRecords.income = income;
    //importworker.insert();
    //dirPerson.RecId=DirPartyTable.RecId;
    DirPerson.insert();
    DirPartyTable.RecId=dirPerson.RecId;
    DirPartyTable.insert();
    DirPersonName.Person=dirPerson.RecId;
    dirpersonname.insert();

    hcmWorker.Person=DirAddressBookPartyAllView.Party;
    hcmWorker.Person=dirPerson.RecId;
    hcmWorker.insert();

        // Hcm Employement Table Data
    HcmEmployment.EmploymentType = HcmEmploymentType::Employee;
    HcmEmployment.LegalEntity = CompanyInfo::find().RecId;
    HcmEmployment.ValidFrom = DateTimeUtil::newDateTime(today(), str2time('00:00:00'));
    HcmEmployment.ValidTo = DateTimeUtil::maxValue();
    HcmEmployment.Worker=hcmWorker.RecId;
    HcmEmployment.insert();

        // Worker Private Details (HCMPersonPrivateDetails)
    HcmPersonPrivateDetails.BirthDate = birthdate;
    HcmPersonPrivateDetails.CitizenshipCountryRegion = CountryCode;
    HcmPersonPrivateDetails.Person = dirPerson.RecId;
    HcmPersonPrivateDetails.insert();

    // Worker Identification Numbers
    RCell = Cells.item(nRow,11);
    if(RCell.value().bStr() != "")
    {
        HcmPersonIdentificationNumber.IdentificationNumber = RCell.value().bStr();
        RCell = Cells.item(nRow,12);
        HcmPersonIdentificationNumber.ExpirationDate = str2DateDMY(RCell.value().bStr());
        HcmPersonIdentificationNumber.Description = "Ikama Number";
        HcmPersonIdentificationNumber.Person      = dirPerson.RecId;
        HcmPersonIdentificationNumber.IdentificationType = 5637145329;
        HcmPersonIdentificationNumber.insert();
    }
    RCell = Cells.item(nRow,14);
    if(RCell.value().bStr() != "")
    {
        HcmPersonIdentificationNumber.IdentificationNumber = RCell.value().bStr();
        RCell = Cells.item(nRow,15);
        HcmPersonIdentificationNumber.ExpirationDate = str2DateDMY(RCell.value().bStr());
        HcmPersonIdentificationNumber.Description = "Passport Number";
        HcmPersonIdentificationNumber.Person      = dirPerson.RecId;
        HcmPersonIdentificationNumber.IdentificationType = 5637145328;
        HcmPersonIdentificationNumber.insert();
    }
    nRow++;
    RCell = Cells.Item(nRow, 1);
    }
    xlsApplication.quit ();
    xlsApplication.finalize ();
    info("Import completed");
    }
    catch( Exception::Error)
    {
    xlsApplication.quit ();
    xlsApplication.finalize ();
    ttsabort;
    info("Unable to process the excel import ");
    }
    }

How to create Production order through X++ code

static void ProdOrderCreation(Args _args)
{
    ProdQty             qty     = 100;
    ItemId                item;
    ProdTable          prodtable;
    InventTable       inventTable;
    InventDim        inventDim;
    item               = 'D0003';


    // Initialize InventTable
    inventTable = inventTable::find(item);

    // Initialize the base values
    prodtable.initValue();
    prodtable.initFromInventTable(inventTable);

    prodtable.ItemId                = inventTable.ItemId;
    prodtable.DlvDate               = today();
    prodtable.QtySched              = qty;
    prodtable.RemainInventPhysical  = qty;

    // Initialize InventDim (Obrigatory)
    inventDim.initValue();

    // Set the active BOM and Route
    prodtable.BOMId = BOMVersion::findActive(prodtable.ItemId,
                                             prodtable.BOMDate,
                                             prodtable.QtySched,
                                             inventDim).BOMId;

    prodtable.RouteId = RouteVersion::findActive(prodtable.ItemId,
                                                 prodtable.BOMDate,
                                                 prodtable.QtySched,
                                                 inventDim).RouteId;

    // Initialize BOMVersion
    prodtable.initBOMVersion();

    // Initialize RouteVersion
    prodtable.initRouteVersion();

    //Use ProdTableType class to create the production order
    prodtable.type().insert();

    // Inform Production Order Id
    setPrefix( 'Production Order');
    setPrefix( 'Production Order Number');
    info(prodtable.ProdId);
}

Monday, October 19, 2015

"Total good quantity reported as finished for the production will be 2.00. Feedback for the last operation is 0.00 in total" issue at production process in AX 2012 R3


If you will find these types of issue like:



















Solution : You have to fill ledger accounts for all required events on Item group.

You can go directly to any Item group via edit any item and then goto Manage Cost section, here you will find Item Group in the starting point. Then right click on it and select View Details option then goto Production section and fill the ledgers.
Task Done.