donderdag 20 november 2014

Find projects that include a specific AOT object

static void FindWhatProjectsObjectExistsIn(Args _args)
{
    ProjectNode         pn;
    ProjectListNode     projectListNode;

    TreeNode            tn, tn2;
    TreeNodeIterator    tni, tni2;

    // Object we are searching for
    TreeNode            tnSearch = TreeNode::findNode(@'\Forms\SalesTable');
    ;

    projectListNode = SysTreeNode::getSharedProject();
    tni = projectListNode.AOTiterator();

    tn = tni.next();

    while (tn)
    {
        pn = tn; // ProjectNode inherits TreeNode
        pn = pn.loadForInspection();

        tni2 = pn.AOTiterator();

        tn2 = tni2.next();

        while (tn2)
        {
            if (tn2.treeNodePath() == tnSearch.treeNodePath())
                info(strfmt("Found in shared project %1", tn.AOTname()));

            // info(tn2.applObjectType()); // Returns the type (Form/Class/Table/Etc)
            // info(tn2.AOTname()); // Returns the object name
            // info(tn2.treeNodePath()); // Returns the object path
            
            tn2 = tni2.next();
        }

        tn = tni.next();
    }
}
 

maandag 13 oktober 2014

Foreground / Background - Report ‘shape’ control issues with PDF Printer

The issue is that ‘shapes’ on reports need to be placed first in their section (first from top to bottom) for the PDF printer to be able to display the text over the shape. It’s a back to front thing where ‘back to front’ corresponds to ‘top to bottom’ on the AX report section.

Source: http://gatesasbait.wordpress.com/2008/09/08/report-shape-control-issues-with-pdf-printer-class-in-dynamics-ax-4-0/

maandag 8 juli 2013

Dimension (Field Value) Search Utility in Dynamics Ax

Source: http://paruvellas.wordpress.com/2012/03/15/dimension-field-value-search-utility-in-dynamics-ax/

In recent days, I got a specific requirement…
At our place, finance controller has decided to close one dimension value and need to replace the same with new dimension value.

To support this, we need to update all the transactions which have old dimension value, to new one.

Assume all the transactions, which are created Dimension [10] – Business unit with value 201, need to update as 203

static void ininspar_Dimension201_Update_Alltables(Args _args)
{
     TreeNode                tn,fn;
     TreeNodeIterator        tni,fni,_tni;
     Str                     objName;
     SysDictField            sysDictField;
     Common                  common;
     Query                   query = new Query();
     QueryBuildDataSource    qbs;
     QueryBuildRange         qbr;
     TableId                 mTableId;
     QueryRun                qr;
     ;

    tn = TreeNode::findNode(“\\Data Dictionary\\Tables”);
     tni = tn.AOTiterator();
     tn = tni.next();

    while (tn)
     {
         objName = tn.treeNodeName();

        tn = tni.next();

        mTableId = tableName2id(objName);
         sysDictField = new SysDictField(mTableId, fieldname2id(mTableId, “Dimension”));  // Finding table object which have Dimension field

        if (sysDictField && Global::hasTableAccess(mTableId))
         {
             //info(objname);
             try
             {
                 qbs = query.addDataSource(mTableId);
                 qbr = qbs.addRange(fieldId2Ext(fieldname2id(mTableId, “Dimension”),10));   // using Dimension[10] in query range
                 qbr.value(“201?);

                qr = new QueryRun(query);
                 while (qr.next())
                 {

                    common = qr.get(mTableId);
                     if (common.RecId)
                     {
                         common.selectForUpdate(true);
                         ttsbegin;
                         common.(fieldId2Ext(fieldname2id(mTableId, “Dimension”),10)) = “203?; //assigning the Dimension[10] value by using Common
                         common.update();
                         ttscommit;
                         info(strfmt(“%1 %2?,objName, int2str(common.RecId)));
                     }
                 }
             }
             catch(Exception::Error)
             {
                 continue;
             }

        }
     }
}
With this, we can write some Advanced Search utilities, to find specific values for some fields for the tables.

donderdag 4 juli 2013

Force delete inventtrans

Source: http://agusriyadi.blogspot.be/2009/08/force-delete-inventtrans.html

Below is sample job to force delete inventtrans, which will take care of invent on hand update.
static void DeleteInventTrans(Args _args)
{
Dialog dlg = new Dialog("Delete inventtrans ?");
DialogField dlgFld;
InventMovement inventMovement;
PurchLine purchLine;
PurchLineRefRecId recId;
;
dlgFld = dlg.addField(typeid(PurchLineRefRecId));
if(dlg.run())
{
recId = dlgFld.value();
purchLine = PurchLine::findRecId(recId);
if(purchLine)
{
InventMovement = InventMovement::construct(purchLine);
InventUpd_DeleteMovement::newMovement(
inventMovement,true).updateNow();
info("done");
}
}
}

On Hand Inventory fields explained

source: http://social.technet.microsoft.com/wiki/contents/articles/6116.dynamics-ax-on-hand-inventory.aspx
MS Dynamics AX 2009 has a very detailed information about inventory items; it gives a comprehensive information regarding stock which gives a clear vision about what in stock, what is reserved for customer or to be issued out, what is ordered from vendor or received in, and what have been posted or still in open transaction.
The below table descript the information in Items On hand form under Inventory Management->Common Forms->Item details->On hand button

Or
it could be accessed through Sales Order/ Purchase Order/Inventory Movement/Production Order under Inventory button->On Hand

#
Label
Description
Comment
1
Physical inventory
Total available quantities
 
2
Physical reserved
Quantities reserved in Sales Order
 
3
Available Physical
Available physical quantities for transactions
3 = 1 – 2
4
Ordered in total
Total quantities in open
Purchase Order
(did not received yet)
 
5
Ordered reserved
Quantities reserved from Purchase Order (did not received yet)
 
6
Available for reservation
Quantities in open Purchase Orders
(did not received yet) available for reservation
6 = 3 + (4 – 5)
7
On order in total
Quantity in open Sales Order
(did not delivered yet)
 
8
Total Available
Net available physical quantities for transaction
8 = 6 – 7
       
9
Posted quantity
Quantities posted financially
 
10
Deducted
Quantities have physical packing list
updates in Sales Order
 
11
Picked
Quantities have picking list
update in Sales Order
 
12
Received
Quantities have physical updates
in Purchase Order
 
13
Registered
Quantities have registered
in Purchase Order
 
       
14
Physical cost amount
Amount posted in ledger physically
 
15
Financial cost amount
Amount posted in leader financially
 
16
Cost price
Item average cost
 

vrijdag 25 januari 2013

Call Non-Static Method Dynamically

http://stackoverflow.com/questions/9098704/dynamics-ax-call-non-static-method-dynamically

public static anytype callMethod(str _className, str _methodName, container _parameters, Object _object = null)
{
    DictClass dictClass;
    anytype returnValue;
    Object object;
    ExecutePermission permission;

    // Grants permission to execute the DictClass.callObject method.
    // DictClass.callObject runs under code access security.
    permission = new ExecutePermission();
    permission.assert();

    if (_object != null)
    {
        dictClass = new DictClass(classidget(_object));
        object = _object;
    }
    else
    {
        dictClass = new DictClass(className2Id(_className));
        object = dictClass.makeObject();
    }

    if (dictClass != null)
    {
        switch (conLen(_parameters))
        {
            case 0:
                returnValue = dictClass.callObject(_methodName, object);
                break;
            case 1:
                returnValue = dictClass.callObject(_methodName, object, conPeek(_parameters, 1));
                break;
            case 2:
                returnValue = dictClass.callObject(_methodName, object, conPeek(_parameters, 1), conPeek(_parameters, 2));
                break;
             //... Continue this pattern for the number of parameters you need to support.
        }
    }

    // Closes the code access permission scope.
    CodeAccessPermission::revertAssert();

    return returnValue;
}

woensdag 2 januari 2013

Custom Lookup - company id

public void lookup()
{
    SysTableLookup sysTableLookup;
    Query query;
    ;

    sysTableLookup = SysTableLookup::newParameters(tablenum(DataArea),this, false);
    sysTableLookup.addLookupfield(fieldnum(DataArea, Id), true);
    sysTableLookup.addLookupfield(fieldnum(DataArea, Name));

    query = new Query();
    query.addDataSource(tablenum(DataArea));
    query.dataSourceTable(tablenum(DataArea)).addRange(fieldnum(DataArea,IsVirtual)).value(int2str(0));
    sysTableLookup.parmQuery(query);

    sysTableLookup.performFormLookup();
}

vrijdag 14 september 2012

How to: Search Application Object Properties

 

Source: http://msdn.microsoft.com/en-us/library/aa661186(v=ax.50).aspx

  1. Click the node that you want to search in the Application Object Tree (AOT).
    For example, click the Tables node to search for a table property.

  2. Press Ctrl+F to open the Find dialog box.

  3. Set the Search field to All nodes.

  4. Type an expression in the Containing text field of the format:

    PropertyName : *#PropertyValue

    For example, to find all instances where the TableGroup property is set to Parameter, type:

    TableGroup: *#Parameter

dinsdag 29 mei 2012

WMS in Microsoft Dynamics AX 2009. Outbound Process Setup

Picking over multiple warehouses can be setup in the shipment reservation sequence.


Shipment reservation sequence


The shipment reservation sequence defines how and where the shipment reservation process reserves. You set up shipment reservation processes under [Inventory management > Setup > Distribution > Shipment reservation sequence].

In this example, the reservation sequence at first tries to reserve inventory from Warehouse 23 and if this warehouse does not have enough physical inventory, Warehouse 22 is the next.




The shipment reservation process contains different layers: Reservation sequence -> Reservation combinations -> Reservation methods.

The reservation combination must be enabled for pallet transports and picking route logic.

Outbound rules

To control the process after picking, an outbound rule must be used and associated with the shipment. In this case, the picked inventory must be delivered to the shipment staging area and it must be loaded before the shipment can be sent.


Source: http://blogs.msdn.com/b/dynamicsaxscm/archive/2009/04/26/wms-in-microsoft-dynamics-ax-2009-outbound-process-setup.aspx

woensdag 16 mei 2012

List tables with changed data as of certain date

 

static void ADU_BMS_TableDataChanged(Args _args)
{
    TableId         tableId;
    Dictionary      dict = new Dictionary();
    SysDictTable    dictTable;
    Common          common;

    TimeZone        tz;
    TransDate       fromDate;
    UtcDateTime     fromDateTime;

    DataArea        dataArea;
    ;

    fromDate = str2date("16042012", 123);
    fromDateTime = datetobeginUtcDateTime(fromDate, tz);

    info(strfmt("Tables with changed data as of %1", fromDateTime));

    while
    select  dataArea
    where   !dataArea.isVirtual
    {
        changeCompany (dataArea.Id)
        {
            // Clear used variables
            tableId     = 0;
            dictTable   = null;
            common      = null;

            // Actions for company
            tableId = dict.tableNext(0);

            while( tableId)
            {
                dictTable = new DictTable(tableId);

                if (!dictTable.isTmp() && !dictTable.isMap() && !dictTable.isView())
                {
                    common = dictTable.makeRecord();

                    select  count(RecId)
                    from    common
                    where   common.createdDateTime  >= fromDateTime
                        ||  common.modifiedDateTime >= fromDateTime;

                    if (common.RecId)
                    {
                        info(strfmt("%1:%2 - %3 changes", dataArea.Id, dictTable.name(), common.RecId ));
                    }
                }

                tableId = dict.tableNext(tableId);
            }

        }
    }

}

woensdag 25 januari 2012

What is MST?

MST is short for "Monetary Standard".

Or also:
MST = Master = Currency of the Company
Cur = Currency (needs also a transdate or exchangeratefield)

AmountMST refers to the base currency you keep your records of the system in, i.e. "Company currency".
So for example when recording an invoice you keep the amounts both in your company currency, i.e. MST (for example DKK), and the invoice currency, for example EUR.

source: http://blogs.msdn.com/b/palle_agermark/archive/2007/04/24/what-is-mst.aspx

maandag 16 januari 2012

Inventory Transaction modifications

STOCK

When stock physically enters or leaves AX, it passes through class InventUpd_Physical.
Methods:

  • UpdatePhysicalReceipt (stock entering)
  • UpdatePhysicalIssue (stock leaving)

Both at line “updPhysical+= inventTrans.Qty”

You can use the movement variable to ask whatever you need to enter into / modify the inventTrans record.

FINANCIAL

Financial values for these transactions are handled the same way, through class InventUpd_Financial.
methods:

  • UpdateFinancialReceipt
  • UpdateFinancialIssue