Create FormLookup

Simply, you can duplicate the form : PBAItemIdLookup

After that, you can use this code in your Lookup method in the form :

public void lookup(FormControl _formControl, str _filterStr)
{
    RecId                       recId;
    Args                        args        = new Args();
    Object                      formRun;
    ;

//    super(_formControl, _filterStr);


    args    = new Args(formstr(MyForm));
    args.caller(element);
    args.record(MyRecord);
    formRun = classfactory.formRunClass(args);
    formRun.init();
    this.performFormLookup(formRun, _formControl);

    //If you need receive an other information from your form, 
    //You can create a parm Method use this like this :
    formRun.wait();
    recId   = formRun.parmRecId();
}
Advertisements

Read and Modify registry settings in Ax

Source : http://colorsofaxapta.spaces.live.com/blog/cns!FB14F6851EBD172E!117.entry

Here is a sample code of increasing max. open cursors during run-time. But, please note that its purpose is only to show you how to read and write registry. If you encounter any open cursors problem, it is recommended to optimize the SQL statement rather than changing the setting for maximum open cursors.

static void IncreaseMaxOpenCursors(Args _args)
{
    #winapi
    container   regRet;    
    int         readReg;
    int         writeReg;
    str         keyValue, keyPath, configName;
    int         maxOpenCursors;
    ;
 
    //Specify your Axapta configuration utility name here
    configName = "LocalMachine";
    //New maximum open cursor, default is 90
    maxOpenCursors = 120;
    keyPath = @"SOFTWARE\Navision\Axapta\3.0\" + configName;
    readReg  = WinAPI::regOpenKey( #HKEY_CURRENT_USER, keyPath, #KEY_READ);
    if (readReg)
    {
        regRet = WinAPI::regGetValue(readReg, 'opencursors');
        keyValue = conpeek(regRet,1);
        info(keyValue);
        if (str2int(keyValue) < maxOpenCursors)
        {
            writeReg  = WinAPI::regOpenKey(#HKEY_CURRENT_USER, keyPath, #KEY_WRITE);
            if (writeReg)
            {
                WinAPI::regSetValueEx(writeReg, 'opencursors', #REG_SZ , maxOpenCursors);
                WinAPI::regCloseKey(writeReg);
            }
            Info("Max open cursors: " + int2str(maxOpenCursors));
        }
        WinAPI::regCloseKey(readReg);
    }
}

Error during sending mail

You can check this post :

You maybe need to change the method new() from the class SysMailer

//NEW CODE - BEGIN
void new(COM c = new COM('CDO.Message')) 
void new(COM c = null)
//NEW CODE - END
{
    COM cdoConfig;
    InteropPermission permission = new InteropPermission(InteropKind::ComInterop);
    ;

    permission.assert();
//NEW CODE - BEGIN
    if (!c)
    {
        c = new COM('CDO.Message');
    }
//NEW CODE - END
    _COM = c;

    //BP Deviation Documented
    if (_COM.configuration() == null)
    {
        //BP Deviation Documented
        cdoConfig =  new COM('CDO.Configuration');
        _configuration = SysMailerConfiguration::create(cdoConfig);
        //BP Deviation Documented
        this.configuration(_configuration);
    }
    else
    {
        //BP Deviation Documented
        _configuration = SysMailerConfiguration::create(_COM.configuration());
    }

    //BP Deviation Documented
    _fields = _configuration.fields();
    _fields.add(#sendUsing,#cdoSendUsingPort);
    _fields.resync();
}

Print PDF file to printer

Source : Palle Agermark on AX

ATTENTION : That’s work ONLY if you have Adobe Reader installed !

Just write this code (and adapt) :

static void pdfprint(Args _args)
{ 
    str                 adobeExe; 
    str                 adobeParm; 

    PrintJobSettings    printJobSettings = new PrintJobSettings(); 
    Dialog              dialog = new Dialog(); 
    DialogField         dialogFileName; 
    ;
    dialogFilename  = dialog.addField(typeid(FilenameOpen));

    if (dialog.run()) 
    {     
        printJobSettings.printerSettings('SysPrintForm');     
        adobeExe = WinAPI::findExecutable(dialogFileName.value());
       
        adobeParm = strFmt(' /t "%1" "%2" "%3" "%4"',
                           dialogFileName.value(),
                           printJobSettings.printerPrinterName(),
                           printJobSettings.printerDriverName(),
                           printJobSettings.printerPortName());

        WinAPI::shellExecute(adobeExe,  adobeParm); 
    }
}

Add inventory dimension

http://blog.mikeyam.com/2009/11/add-new-inventory-dimension.html

Dynamics AX 2009 includes the following inventory storage dimensions from the packaging:

  • Warehouse
  • Batch number
  • Location
  • Pallet ID
  • Serial

and item dimensions:

  • Configuration
  • Color
  • Size

Sometimes it may not be enough for the business needs. To add a new dimension, you can follow the steps below:

  1. First, I assume you have create the dimension tables (similar to InventColor, InventBatch)
  2. Add the key field into the table InventDim.
  3. Then add to the field group InventDimensions and InventoryDimensions
  4. Add fields to the DimIdx as well as relations if necessary.
  5. And then modify some methods if InventDim, just goes thru all methods.
  6. Add fields to InventDimParm also.
  7. Modify macro InventDimJoin and InventDimSelect.
  8. The most important things is do a seach at the top of AOT with #InventDimDevelop as the keywords.
  9. Do a complete Recompilation of all stuffs.
  10. Finish!

You are suggested to add all new dimensions before the system implementation. If there’s some open transaction, weird things may happen. So add some spare dimension if necessary.


https://mbs.microsoft.com/knowledgebase/kbdisplay.aspx?wtntzsmnwukntmmymxtyykswtlkqnnoxvxyqnmwqqqsrnvpy

Issue

How to add another inventory dimension in Axapta 2.5.

Resolution

In Axapta 2.5, five standard inventory dimensions exist: Warehouse, Batch number, Location, Pallet, and Serial number. Follow the steps below to add another dimension.

1. If necessary, create a new extended data type to base the new dimension on.

2. Create the new field in the InventDim table. Add the field to the field group “Inventory Dimensions”.

3. Create a new field in the InventDimParm table. The field must be an Enum based on the NoYesId extended data type. Add the field to the field groups “View” and “Fixed view”.

4. Go to the top of the AOT and do a Find (ctrl+F). Find all occurrences of #InventDimDevelop. The methods returned represent methods to consider when adding new inventory dimensions.

5. Insert the new InventDim field in relevant form grids.

6. Do a complete recompilation of Axapta.

This article was TechKnowledge Document ID: 28677