Friday 10 January 2014

Change form background color in dynamics Ax


1.  Class Name : SysSetupFormRun


   Overrides the run method with following code


public void run()
{
    int red;
    int yellow;
    ;


    super();


    red  = WinAPI::rgb2int(255,0,0);
    yellow  = WinAPI::rgb2int(204,255,0);


    this.design().colorScheme(FormColorScheme::RGB);


    switch(curext())
    {
        case "DAS":
            this.design().backgroundColor(red);
            break;


        case "DMO":
            this.design().backgroundColor(yellow);
            break;


        default:
            break;
    }
}


Thursday 9 January 2014

Export data from Ax 2009 to Excel file in Ax 2009

class ExcelExport
{
}
and right click and select new method and type the code as follows
public static void main(Args args)
{
CustTable custTable;
SysExcelApplication application;
SysExcelWorkBooks workbooks;
SysExcelWorkBook workbook;
SysExcelWorksheets worksheets;
sysExcelWorksheet worksheet;
SysExcelCells cells;
SysExcelCell cell;
int row;
;
application = sysExcelApplication::construct();
workbooks = application.workbooks();
workbook= workbooks.add();
worksheets = workbook.worksheets();
worksheet = worksheets.itemFromNum(1);
cells = worksheet.cells();
cells.range('A:A').numberFormat('@');
while select custTable
//The following loop will provide the data to be populated in each column
{
row++;
cell = cells.item(row,1);
cell.value(custTable.AccountNum);
cell = cells.item(row,2);
cell.value(custTable.Name);
cell = cells.item(row,3);
cell.value(CustTable.CustGroup);
cell = cells.item(row,4);
cell.value(CustTable.Currency);
cell = cells.item(row,5);
cell.value(CustTable.CreditMax);
cell = cells.item(row,6);
cell.value(CustTable.CreditRating);
}
application.visible(true); // opens the excel worksheet
}
By this code you can export all the customers to excel and this export can also be done on other ways
In Administration-->Periodic--->Data export/import---->Excel speardsheets--->Template wizard
In this template wizard ---->Next--->Open workbook(create an excel file with it)--->next--->Available objects(tables) and move your required tables to Selected objects--->Next--->Select the fields(if required)--->Create Import definition group--->Check Export data and Finish...
I think this code will help in exporting to excel

Export data from Ax 2009 to Excel file in Ax 2009

class ExcelExport
{
}
and right click and select new method and type the code as follows
public static void main(Args args)
{
CustTable custTable;
SysExcelApplication application;
SysExcelWorkBooks workbooks;
SysExcelWorkBook workbook;
SysExcelWorksheets worksheets;
sysExcelWorksheet worksheet;
SysExcelCells cells;
SysExcelCell cell;
int row;
;
application = sysExcelApplication::construct();
workbooks = application.workbooks();
workbook= workbooks.add();
worksheets = workbook.worksheets();
worksheet = worksheets.itemFromNum(1);
cells = worksheet.cells();
cells.range('A:A').numberFormat('@');
while select custTable
//The following loop will provide the data to be populated in each column
{
row++;
cell = cells.item(row,1);
cell.value(custTable.AccountNum);
cell = cells.item(row,2);
cell.value(custTable.Name);
cell = cells.item(row,3);
cell.value(CustTable.CustGroup);
cell = cells.item(row,4);
cell.value(CustTable.Currency);
cell = cells.item(row,5);
cell.value(CustTable.CreditMax);
cell = cells.item(row,6);
cell.value(CustTable.CreditRating);
}
application.visible(true); // opens the excel worksheet
}
By this code you can export all the customers to excel and this export can also be done on other ways
In Administration-->Periodic--->Data export/import---->Excel speardsheets--->Template wizard
In this template wizard ---->Next--->Open workbook(create an excel file with it)--->next--->Available objects(tables) and move your required tables to Selected objects--->Next--->Select the fields(if required)--->Create Import definition group--->Check Export data and Finish...
I think this code will help in exporting to excel

Simple Dialog Box Example in Ax 2009

static void Simple_Dialog(Args _args)
{
dialog dlg;
dialogGroup dlgGroup;
dialogField dlgField;
;
dlg = new dialog("Simple Dialog");
dlgGroup = dlg.addGroup("Customer");
dlgField = dlg.addField(TypeID(custAccount),"Account
Number");
if (dlg.run())
{
print dlgField.value();
pause;
}
}

how to export data from Ax 2009 to Excel sheet through code . The code is , open the class , new class in class declaration type


class ExcelExport
{
}
and right click and select new method and type the code as follows
public static void main(Args args)
{
CustTable custTable;
SysExcelApplication application;
SysExcelWorkBooks workbooks;
SysExcelWorkBook workbook;
SysExcelWorksheets worksheets;
sysExcelWorksheet worksheet;
SysExcelCells cells;
SysExcelCell cell;
int row;
;
application = sysExcelApplication::construct();
workbooks = application.workbooks();
workbook= workbooks.add();
worksheets = workbook.worksheets();
worksheet = worksheets.itemFromNum(1);
cells = worksheet.cells();
cells.range('A:A').numberFormat('@');
while select custTable
//The following loop will provide the data to be populated in each column
{
row++;
cell = cells.item(row,1);
cell.value(custTable.AccountNum);
cell = cells.item(row,2);
cell.value(custTable.Name);
cell = cells.item(row,3);
cell.value(CustTable.CustGroup);
cell = cells.item(row,4);
cell.value(CustTable.Currency);
cell = cells.item(row,5);
cell.value(CustTable.CreditMax);
cell = cells.item(row,6);
cell.value(CustTable.CreditRating);
}
application.visible(true); // opens the excel worksheet
}
By this code you can export all the customers to excel and this export can also be done on other ways
In Administration-->Periodic--->Data export/import---->Excel speardsheets--->Template wizard
In this template wizard ---->Next--->Open workbook(create an excel file with it)--->next--->Available objects(tables) and move your required tables to Selected objects--->Next--->Select the fields(if required)--->Create Import definition group--->Check Export data and Finish...
I think this code will help in exporting to excel

Wednesday 8 January 2014

workflows in Project management and accounting AX 2012

there are two types of workflow types that have been added to set up workflow in Microsoft Dynamics AX 2012 specific to timesheet:
  • Review timesheet workflow (TSDocumentTemplate) - approval workflows for project timesheets at the document level
  • Review timesheet line workflow  (TSTimesheetLineTemplate) - approval workflows for project timesheets at the line item level
Review timesheet workflow is the main workflow of timesheets, which is used for the approval process during timesheet entry. The setup of Review timesheet workflow contains two workflow elements for the approval depending on approval level you desire in your system:
  • Approve timesheet: It is used to define the approval at document level or timesheet header level.
  • Timesheet line-item workflow: It is used to define the approval at the detail line level. In such case, you should set up a new workflow of type Review timesheet line workflow and join the new workflow to this workflow element belonging to the main workflow type Review timesheet workflow.
 

Review timesheet line workflow must be added to the main Review timesheet workflow, because it cannot operate on its own. To define Review timesheet line workflow:
1.       Click Project management and accounting.
2.       Click Setup and then click on Project management and accounting workflows where you will selectReview timesheet line workflow.
 
3.       Configure the workflow structure according to your needs using supported elements (Approve a timesheet line, Condditional decision, Manual decision, Parallel activity, Subworkflow)
 
4.       In this example we have assigned the approval to workflow participant – Project manager. In this case the line approval task will be assigned to Project manager responsible for the project specified on the line.

5.       Once you are finished close the workflow, save it and activate it.

Now it is necessary to link Review timesheet line workflow to the main workflow Review timesheet workflow:
1.       Click Project management and accounting.
2.       Click Setup and then click on Project management and accounting workflows where you will selectReview timesheet workflow.
3.       Configure the workflow structure like in previous step, but note the new element Timesheet line-item workflow. Add this element to the workflow processing and open its properties.
4.       There are two possibilities in the current design of AX 2012:
    • Use a single workflow for all line-items
    • Use separate workflow for each line-item – could be useful when different workflow process is required for each Project ID:

Note: You must define at least two conditions and an associated workflow within a line-item workflow element.
6.       Once you finish the workflow setup - close it, save it and activate it.

Testing
When a new timesheet with 2 lines is submitted to the workflow – system splits the processing into two separate streams:
 

User can check each line workflow by selecting the line and click Actions > View history:
 

  
Note: In Microsoft Dynamics AX 2009, the approval level is defined within timesheet parameters. It is removed in Microsoft Dynamics AX 2012.

Tuesday 7 January 2014

Code / job to import CSV / Excel to CustTable in Dynamic AX 2012


1.Prepare the CSV (If it was excel convert ti CSV)  file containing following fields in same order as below
Customer account
English Name
English Search Name
Invoice account
Customer group
Terms of payment
Currency
One-time customer
Country/region
Delivery terms
Mode of delivery
Misc. charges group
Language

2. Create a class using below codes and just run by using |> run button or F5

public class CustomerMasterImport extends RunBase
{
    CommaIo                     csvFile;
    Filename                    filename;
    DialogField                 dialogFilename;
    #define.CurrentVersion(2)
    #localmacro.CurrentList
    filename,
    insertIncorrectRecords,
    #endmacro
    #localmacro.ListVersion1
    filename,
    insertIncorrectRecords
    #endmacro
    #File
}
/*********************************************/
public Object dialog()
{
    DialogRunbase       dialog = super();
    ;
    dialogFilename  = dialog.addField(extendedTypeStr(FilenameOpen));
    dialogFilename.value(filename);
    dialog.filenameLookupFilter(["All files", #AllFiles]);
    return dialog;
}
/********************************************/
public boolean getFromDialog()
{
    filename                = dialogFilename.value();
    return true;
}
/*******************************************/
void run()
{
    //CommaTextIO                             csvFile;
    container                               readCon;
    counter                                 icount,inserted;
    Dialog                                  dialog;
    DialogField                             dfFileName;
    DirPartyRecId                           partyRecId,contactPartyRecid;
    Name                                    name,contactName;
    CustTable                               vendtable;
   // VendTable                               vendtable;
    str                                     contactperson;
    DirPartyPostalAddressView               addressView;
    DirPartyContactInfoView                 contactView;
    ContactPerson                           contactpersonTable;
    LogisticsElectronicAddressMethodType    enumType;
    DirContactPersonsService                dirContactPersonsService;
    DirContactPersons                       dirContactPersons;
    DirContactPersons_ContactPerson         dirContactPersons_ContactPerson;
    DirContactPersons_Person                dirContactPersons_Person;
    DirContactPersons_PersonName            dirContactPersons_PersonName;
    AifEntityKeyList                        aifEntityKeyList, aifEntityKeyList_DirContactPerson;
    str                                     fName, mName, lName;
    VendAccount                             vendorAccount;
    DirParty                                dirParty;
    LogisticsPostalAddress                  address;
    LogisticsElectronicAddress              logisticsElectronicAddress;
    BinData                                 binData;
    str                                     stringImage;
    LogisticsAddressStateID                 stateId;
    str                                     accountnum,accountName,vendgroup,currency,dlvmode,paymtermid,countryid,street,city,mobile,fax,email,zipcode,pobox,phone;
    //
    CustInvoiceAccount  invoiceaccount;
    LogisticsAddressCountryRegionId  countryregion;

    NoYes               ontimecustomer;
    CustDlvTermId       termid;
    CustMarkupGroupId   chargegroup;
    ItemBuyerGroupId    buyergroupid;
    ;

    csvFile = new CommaIO(filename, 'r');
    try
    {
        if (csvFile)
        {
            readCon = csvFile.read();
            while (csvFile.status() == IO_Status::OK)
            {
                readCon = csvFile.read();
                if(readCon)
                {
                icount++;
                accountnum = conPeek(readCon,1);
                accountName = conPeek(readCon,2);
                name = conPeek(readCon,3);
                invoiceaccount = conPeek(readCon,4);
                vendgroup = conPeek(readCon,5);
                paymtermid = conPeek(readCon,6);
                currency = conPeek(readCon,7);
                ontimecustomer = conPeek(readCon,8);
                countryregion= conPeek(readCon,9);
                termid=conPeek(readCon,10);
                dlvmode = conPeek(readCon,11);
                chargegroup = conPeek(readCon,12);
                if(!name)
                break;
                partyRecId = DirPartyTable::createNew( DirPartyType::Organization, name).RecId;
                vendtable.clear();
                vendtable.initValue();
                vendtable.Party = partyRecId;
                vendtable.AccountNum = accountnum;
                vendtable.CustGroup  = vendgroup;
                vendtable.Currency   = currency;
                vendtable.DlvMode    = dlvmode;
                vendtable.PaymTermId   = paymtermid;
                vendtable.OneTimeCustomer   =  ontimecustomer;
                vendtable.DlvTerm =termid;
                    vendtable.DlvMode = dlvmode;
                   vendtable.MarkupGroup = chargegroup;
                    vendtable.InvoiceAccount = invoiceaccount;
                    vendtable.PartyCountry = countryregion;
                if(contactperson != '')
                {
                    contactname = ContactPerson;
                    ContactPerson::findOrCreateNameParty(partyRecId,contactname);
                }
               vendtable.insert();
                stateId = subStr(stateId,1,25);
                address.PostBox = strLRTrim(PoBox);
                address.CountryRegionId = strLRTrim(Countryid);
                address.State = stateId;
                address.ZipCode = strLRTrim(ZipCode);
                address.Street  = strLRTrim(Street);
                address.county = countryregion;
                address.City    = strLRTrim(City);
                addressView.LocationName = name;
                addressView.IsPrimary = NoYes::Yes;
                addressView.Party = partyRecId;
                addressview.initFromPostalAddress(address);

                DirParty = DirParty::constructFromPartyRecId(addressView.Party );
                DirParty.createOrUpdatePostalAddress(addressView);
         inserted++;
                }
            }
        }
        icount--;//Remove header recount from total record count
    }
    catch(Exception::Error)
    {
        info(strFmt("%1 %2",Exception::Error,icount));
    }
}
/***********************************************/
static void main(Args  args)
{
    CustomerMasterImport        VendorMasterImport;
    ;
    VendorMasterImport =  new CustomerMasterImport();
    if(VendorMasterImport.prompt())
    {
        VendorMasterImport.run();
    }
}
/*********************************************/
3. Now you will find a browser like this.

4. Select your CSV file and proceed.

Regards,

Posting a general journal in ax 2012 through X++


1. Open General ledger | Journals | General journal, and find previously created
journal or manually create a new one. Note the journal's number.
2. In the AOT, create a new job named LedgerJournalPost with the following code
(replace the text 000420_010 with the journal's number from the previous step):
static void LedgerJournalPost(Args _args)
{
LedgerJournalCheckPost jourPost;
LedgerJournalTable jourTable;
jourTable = LedgerJournalTable::find('000420_010');
jourPost = LedgerJournalCheckPost::newLedgerJournalTable(
jourTable,
NoYes::Yes);
jourPost.run();

Processing a project journal in ax 2012 through X++

1.In the AOT, create a new job named ProjJournalCreate with the following code:

static void ProjJournalCreate(Args _args)
{
ProjJournalTable jourTable;
ProjJournalTrans jourTrans;
ProjJournalTableData jourTableData;
ProjJournalTransData jourTransData;
ProjJournalStatic jourStatic;
ttsBegin;
jourTableData = JournalTableData::newTable(jourTable);
jourTable.JournalId = jourTableData.nextJournalId();
jourTable.JournalType = ProjJournalType::Hour;
jourTable.JournalNameId = 'Hours';
jourTableData.initFromJournalName(
ProjJournalName::find(jourTable.JournalNameId));
jourStatic = jourTableData.journalStatic();
jourTransData = jourStatic.newJournalTransData(
jourTrans,
jourTableData);
jourTransData.initFromJournalTable();
jourTrans.initValue();
jourTrans.ProjId = '10001';
jourTrans.initFromProjTable(
                ProjTable::find(jourTrans.ProjId));
jourTrans.TransDate = systemDateGet();
jourTrans.ProjTransDate = jourTrans.TransDate;
jourTrans.CategoryId = 'Design';
jourTrans.setHourCostPrice();
jourTrans.setHourSalesPrice();
jourTrans.TaxItemGroupId =
ProjCategory::find(jourTrans.CategoryId).TaxItemGroupId;
jourTrans.Worker =
HcmWorker::findByPersonnelNumber('000062').RecId;
jourTrans.Txt = 'Design documentation';
jourTrans.Qty = 8;
jourTransData.create();
jourTable.insert();
ttsCommit;
info(strFmt(
"Journal '%1' has been created", jourTable.JournalId));
}

2. Run the job and check the results by going to Project management and accounting | Journals | Hour:

Posting Project Journal through X++ in ax 2012


static void ProjJournalPost(Args _args)
{
ProjJournalCheckPost jourPost;
jourPost = ProjJournalCheckPost::newJournalCheckPost(
true,
true,
JournalCheckPostType::Post,
tableNum(ProjJournalTable),
'PJJ_000657');
jourPost.run();

       }

Abstract Modifier in ax 2012


Abstract Modifier
An abstract class or method is the exact opposite of a final. The use of abstract classes is
a way of planning inheritance as it forces creating a subclass for using the class, as an
abstract class cannot be declared. This is often used in the standard package for super
classes to control that the super class is not declared by mistake. The class
SalesFormLetter which is used for creating documents such as sales confirmations and
sales invoices uses this practice. The class has an construct() method which should be
used, and to prevent the class being declared using new() SalesFormLetter is qualified
as abstract.
abstract CustAccount myAbstractMethod()
{
// The code in this method is never executed
#if.never
select firstonly custTable
where custTable;
#endif
}
Methods can be declared as abstract, but only if the class is abstract. An abstract method
must be overridden as an abstract method cannot have a code block. Abstract methods
contains only a parameter profile. You can however use the macro call #if.never to add
"code" to an abstract method. This will help clarify why this method must be overridden
in the subclass. You might wonder why you should not simply add comments in the
abstract method. The point is that code within the macro call is shown in color as with
any other code in the editor making it easier to differentiate comments and code. Note
that no validation is done on code written in the #if.never macro so anything could be
written. It is optional to qualify methods of an abstract class as abstract. For this reason
you will still be able to add variables in the ClassDeclaration of an abstract class..
The access modifiers protected can be use with abstract methods. An abstract method
cannot be static, as the static methods only exist in the super class

Write data to a text file through X++ in ax 2012


static void WriteTextfile(Args _args)
{
    CustTable   custTable;
    BinData     binData;
    TextBuffer  textBuffer;
    ;

    textBuffer = new TextBuffer();
    textBuffer.setText('');

    while select custTable where custTable.AccountNum < '40020'
    {
        textBuffer.appendText(strfmt('%1\r\n',custTable.AccountNum));
    }

    textBuffer.getText();

    binData = new BinData();
    binData.setStrData(textBuffer.getText());
    binData.saveFile(@"d:\iba.txt");

}
________________________________________________________________________________
static server void WriteTextFile(Args _args)
{
TextIo file;
// Using the @ before the filename
// enables us to use single path
// delimiters. If you don't use it
// you will have to write the path like this:
// "c:\\temp\\cars.txt"
FileName filename = @"c:\temp\cars.txt";
CarTable carTable;
container con;
FileIoPermission permission;
#File
;
try
{
// Create the permission class
permission = new FileIoPermission(filename, #io_write);
// Add a request for permission before new TextIo()
permission.assert();
// Create the TextIo object
file = new TextIo(filename, #io_write);
if (!file)
throw Exception::Error;
// Specify the delimiters
file.outRecordDelimiter(#delimiterCRLF);
file.outFieldDelimiter(";");
// Loop through the data source
while select carTable
{
// Empty the container
con = connull();
// Set the data into the container
con = conins(con, 1, carTable.CarId);
con = conins(con, 2, carTable.CarBrand);
con = conins(con, 3, carTable.Mileage);
con = conins(con, 4, carTable.Model);
con = conins(con, 5, carTable.ModelYear);
// Write the container to the file
file.writeExp(con);
}
}
catch(Exception::Error)
{
error("You do not have access to write the file to the
selected folder");
}
// Revert the access privileges
CodeAccessPermission::revertAssert();
}
(OR)
while select carTable
{
// Write the data to the file
file.write(carTable.CarId,
carTable.CarBrand,
carTable.Mileage,
carTable.Model,
carTable.ModelYear);
}

Create and posting Sales order through X++ in ax 2012


static void createSalesTable(CustAccount _custAccount)
{
SalesTable salesTable;
NumberSeq NumberSeq;
;
NumberSeq = NumberSeq::newGetNumFromCode(SalesParameters::numRefSalesId().numberSequence);
salesTable.SalesId = NumberSeq.num();
salesTable.initValue();
salesTable.CustAccount = _custAccount;
salesTable.initFromCustTable();
salesTable.insert();
}
Example: Create a Sales Line
static void createSalesLine(SalesId _salesId, ItemId _itemId)
{
SalesLine salesLine;
;
salesLine.clear();
salesLine.SalesId = _salesId;
salesLine.ItemId = _itemId;
salesLine.createLine(NoYes::Yes, // Validate
NoYes::Yes, // initFromSalesTable
NoYes::Yes, // initFromInventTable
NoYes::Yes, // calcInventQty
NoYes::Yes, // searchMarkup
NoYes::Yes); // searchPrice
}
//Code for posting Sales order Invoice
static void createSalesOrder(Args _args)
{
SalesFormLetter formLetterObj;
formLetterObj = SalesFormLetter::construct(DocumentStatus::Invoice);
formLetterObj.update(SalesTable::find( gSO-101248  ));
}

Create Purchase Order_and_Invoice in ax 2012


static void Dev_CreatePO_and_Invoice(Args _args)
{
NumberSeq numberSeq;
Purchtable Purchtable;
PurchLine PurchLine;
PurchFormLetter purchFormLetter;
;
ttsbegin;
numberSeq = NumberSeq::newGetNumFromCode(purchParameters::numRefPurchaseOrderId().NumberSequence,true);
// Initialize Purchase order values
Purchtable.initValue();
Purchtable.PurchId = numberSeq.num();
Purchtable.OrderAccount = '3000';
Purchtable.initFromVendTable();
if (!Purchtable.validateWrite())
{
throw Exception::Error;
}
Purchtable.insert();
// Initialize Purchase Line items
PurchLine.PurchId = Purchtable.PurchId;
PurchLine.ItemId = 'B-R14';
PurchLine.createLine(true, true, true, true, true, false);
ttscommit;
purchFormLetter = purchFormLetter::construct(DocumentStatus::Invoice);
purchFormLetter.update(purchtable, // Purchase record Buffer
"Inv_"+purchTable.PurchId, // Invoice Number
systemdateget()); // Transaction date
if (PurchTable::find(purchTable.PurchId).DocumentStatus == DocumentStatus::Invoice)
{
info(strfmt("Posted invoiced journal for purchase order %1",purchTable.PurchId));
}
}

Access rights to SharePoint in ax 2012


Access to SharePoint
1. Open Internet Explorer
2. Click Site Actions > Site Permissions
3. Click Grant Permissions
4. In the Users\Groups box, enter Tony
5. Click Check Names
6. Check Full Control
7. Click OK

Field1_1_modified and Fld_7_lookup on the dilaog through X++ ax 2009


public void dialogPostRun(DialogRunbase _dialog)
{
    super(_dialog);

    _dialog.dialogForm().formRun().controlMethodOverload(true);
    _dialog.dialogForm().formRun().controlMethodOverloadObject(this);
}

Note, that in the code above the RunBase class itself is used as event handler (by passing this to the controlMethodOverloadObject() method), but it is possible to create a separate class for handling events.

Afterwards event handlers can be created as method with specific name: _. Control name can be found in the dialog user setup. For example, the following method will handle modify event of the first field control on the dialog:
public void fld1_1_modified()
{
    Object control;

    control = dialog.formRun().controlCallingMethod();

    if(control.modified())
    {
        info(“Modified triggered!”);
    }
 
public Object dialog(DialogRunbase _dialog, boolean _forceOnClient)
{
    DialogRunBase   dialog;
    ;

    dialog = super(_dialog, true);

    dialog.caption('@RID2885');

    dfItem = dialog.addField(typeid(ItemId));
    dfInventLoc = dialog.addField(typeid(InventLocationId));
    dfReplaceCost = dialog.addField(typeid(PdsCost));
    dfItemConfig = dialog.addField(typeid(ConfigId));
    dfColorId = dialog.addField(typeid(InventColorId), '@RID101');

    return dialog;
}
void Fld_7_lookup()

{

    Formrun fr = this.dialogModify().parmDialog();

    Object control = fr.controlCallingMethod();    

    ;

    ConfigTable::lookupConfigIdSimple(control, dfItem.value());    

}
public void dialogPostRun(DialogRunbase _dialog)

{

    ;

     super(_dialog);

    **_dialog.formRun().controlMethodOverload(true);** // Causes Stack Trace error

    _dialog.formRun().controlMethodOverloadObject(this);       

}

Mayby you should call super(_dialog) last in the dialogPostRun method.
Here is an example code for overriding the modified method. Maybe lookup has the same requirements:
public void dialogPostRun(DialogRunbase _dialog)
{
// Must be overriden to enable overriding modified method
;
    _dialog.dialogForm().formRun().controlMethodOverload(true);
    _dialog.dialogForm().formRun().controlMethodOverloadObject(this);
    _dialog.formRun().controlMethodOverload(true);
    _dialog.formRun().controlMethodOverloadObject(this);

    super(_dialog);
}
And for the custom method:
boolean Fld2_1_modified()
{
    FormStringControl c = dialog.formrun().controlCallingMethod();
    boolean ret;
    ;

    ret = c.modified(); // Super() Call the FormControl ->modified

    dlgCustomField.value(MyClass::someMethod(dlgCustomField.value())); // example

    return ret;
}
public Object dialog(DialogRunbase _dialog, boolean _forceOnClient)
{
    DialogRunBase   dialog;
    ;

    dialog = super(_dialog, true);

    dialog.caption('@RID2885');

    dfItem = dialog.addField(typeid(ItemId));
    dfInventLoc = dialog.addField(typeid(InventLocationId));
    dfReplaceCost = dialog.addField(typeid(PdsCost));
    dfItemConfig = dialog.addField(typeid(ConfigId));
    dfColorId = dialog.addField(typeid(InventColorId), '@RID101');

    return dialog;
}
Here's the call to the lookup():
void Fld_7_lookup()
{
    Formrun fr = this.dialogModify().parmDialog();
    Object control = fr.controlCallingMethod();
    ;

    ConfigTable::lookupConfigIdSimple(control, dfItem.value());
}
And this is where it keeps getting the Stack Trace error:
public void dialogPostRun(DialogRunbase _dialog)
{
    ;
     super(_dialog);
    **_dialog.formRun().controlMethodOverload(true);** // Causes Stack Trace error
    _dialog.formRun().controlMethodOverloadObject(this);   
}
Mayby you should call super(_dialog) last in the dialogPostRun method.

Here is an example code for overriding the modified method. Maybe lookup has the same requirements:
public void dialogPostRun(DialogRunbase _dialog)
{
// Must be overriden to enable overriding modified method
;
    _dialog.dialogForm().formRun().controlMethodOverload(true);
    _dialog.dialogForm().formRun().controlMethodOverloadObject(this);
    _dialog.formRun().controlMethodOverload(true);
    _dialog.formRun().controlMethodOverloadObject(this);

    super(_dialog);
}
And for the custom method:
boolean Fld2_1_modified()
{
    FormStringControl c = dialog.formrun().controlCallingMethod();
    boolean ret;
    ;

    ret = c.modified(); // Super() Call the FormControl ->modified

    dlgCustomField.value(MyClass::someMethod(dlgCustomField.value())); // example

    return ret;
}
public void dialogPostRun(DialogRunbase _dialog)
{
    super(_dialog);

    _dialog.dialogForm().formRun().controlMethodOverload(true);
    _dialog.dialogForm().formRun().controlMethodOverloadObject(this);
}

Note, that in the code above the RunBase class itself is used as event handler (by passing this to the controlMethodOverloadObject() method), but it is possible to create a separate class for handling events.

Afterwards event handlers can be created as method with specific name: _. Control name can be found in the dialog user setup. For example, the following method will handle modify event of the first field control on the dialog:
public void fld1_1_modified()
{
    Object control;

    control = dialog.formRun().controlCallingMethod();

    if(control.modified())
    {
        info(“Modified triggered!”);
    }

fld1_1_modified and Fld_7_lookup on the dilaog through X++ ax 2009


public void dialogPostRun(DialogRunbase _dialog)
{
    super(_dialog);

    _dialog.dialogForm().formRun().controlMethodOverload(true);
    _dialog.dialogForm().formRun().controlMethodOverloadObject(this);
}

Note, that in the code above the RunBase class itself is used as event handler (by passing this to the controlMethodOverloadObject() method), but it is possible to create a separate class for handling events.

Afterwards event handlers can be created as method with specific name: _. Control name can be found in the dialog user setup. For example, the following method will handle modify event of the first field control on the dialog:
public void fld1_1_modified()
{
    Object control;

    control = dialog.formRun().controlCallingMethod();

    if(control.modified())
    {
        info(“Modified triggered!”);
    }
 
public Object dialog(DialogRunbase _dialog, boolean _forceOnClient)
{
    DialogRunBase   dialog;
    ;

    dialog = super(_dialog, true);

    dialog.caption('@RID2885');

    dfItem = dialog.addField(typeid(ItemId));
    dfInventLoc = dialog.addField(typeid(InventLocationId));
    dfReplaceCost = dialog.addField(typeid(PdsCost));
    dfItemConfig = dialog.addField(typeid(ConfigId));
    dfColorId = dialog.addField(typeid(InventColorId), '@RID101');

    return dialog;
}
void Fld_7_lookup()

{

    Formrun fr = this.dialogModify().parmDialog();

    Object control = fr.controlCallingMethod();    

    ;

    ConfigTable::lookupConfigIdSimple(control, dfItem.value());    

}
public void dialogPostRun(DialogRunbase _dialog)

{

    ;

     super(_dialog);

    **_dialog.formRun().controlMethodOverload(true);** // Causes Stack Trace error

    _dialog.formRun().controlMethodOverloadObject(this);       

}

Mayby you should call super(_dialog) last in the dialogPostRun method.
Here is an example code for overriding the modified method. Maybe lookup has the same requirements:
public void dialogPostRun(DialogRunbase _dialog)
{
// Must be overriden to enable overriding modified method
;
    _dialog.dialogForm().formRun().controlMethodOverload(true);
    _dialog.dialogForm().formRun().controlMethodOverloadObject(this);
    _dialog.formRun().controlMethodOverload(true);
    _dialog.formRun().controlMethodOverloadObject(this);

    super(_dialog);
}
And for the custom method:
boolean Fld2_1_modified()
{
    FormStringControl c = dialog.formrun().controlCallingMethod();
    boolean ret;
    ;

    ret = c.modified(); // Super() Call the FormControl ->modified

    dlgCustomField.value(MyClass::someMethod(dlgCustomField.value())); // example

    return ret;
}
public Object dialog(DialogRunbase _dialog, boolean _forceOnClient)
{
    DialogRunBase   dialog;
    ;

    dialog = super(_dialog, true);

    dialog.caption('@RID2885');

    dfItem = dialog.addField(typeid(ItemId));
    dfInventLoc = dialog.addField(typeid(InventLocationId));
    dfReplaceCost = dialog.addField(typeid(PdsCost));
    dfItemConfig = dialog.addField(typeid(ConfigId));
    dfColorId = dialog.addField(typeid(InventColorId), '@RID101');

    return dialog;
}
Here's the call to the lookup():
void Fld_7_lookup()
{
    Formrun fr = this.dialogModify().parmDialog();
    Object control = fr.controlCallingMethod();
    ;

    ConfigTable::lookupConfigIdSimple(control, dfItem.value());
}
And this is where it keeps getting the Stack Trace error:
public void dialogPostRun(DialogRunbase _dialog)
{
    ;
     super(_dialog);
    **_dialog.formRun().controlMethodOverload(true);** // Causes Stack Trace error
    _dialog.formRun().controlMethodOverloadObject(this);   
}
Mayby you should call super(_dialog) last in the dialogPostRun method.

Here is an example code for overriding the modified method. Maybe lookup has the same requirements:
public void dialogPostRun(DialogRunbase _dialog)
{
// Must be overriden to enable overriding modified method
;
    _dialog.dialogForm().formRun().controlMethodOverload(true);
    _dialog.dialogForm().formRun().controlMethodOverloadObject(this);
    _dialog.formRun().controlMethodOverload(true);
    _dialog.formRun().controlMethodOverloadObject(this);

    super(_dialog);
}
And for the custom method:
boolean Fld2_1_modified()
{
    FormStringControl c = dialog.formrun().controlCallingMethod();
    boolean ret;
    ;

    ret = c.modified(); // Super() Call the FormControl ->modified

    dlgCustomField.value(MyClass::someMethod(dlgCustomField.value())); // example

    return ret;
}
public void dialogPostRun(DialogRunbase _dialog)
{
    super(_dialog);

    _dialog.dialogForm().formRun().controlMethodOverload(true);
    _dialog.dialogForm().formRun().controlMethodOverloadObject(this);
}

Note, that in the code above the RunBase class itself is used as event handler (by passing this to the controlMethodOverloadObject() method), but it is possible to create a separate class for handling events.

Afterwards event handlers can be created as method with specific name: _. Control name can be found in the dialog user setup. For example, the following method will handle modify event of the first field control on the dialog:
public void fld1_1_modified()
{
    Object control;

    control = dialog.formRun().controlCallingMethod();

    if(control.modified())
    {
        info(“Modified triggered!”);
    }

SQL/SSRS Interview questions I thought of blogging some SQL/SSRS interview questions.

Below are some. I will add more, when I complete the compilation 1. What is OLTP(Online Transaction Processing)? OLTP stands ...