vrijdag 10 september 2010

Dimension active?

Method on InventTable

public boolean isConfigIdActive()
{
    InventDimSearch dimSearch = new InventDimSearch();
    ;
    if (dimSearch.find(this.DimGroupId,fieldnum(InventDim,ConfigId)))
        return dimSearch.dimActive();
    return false;
}

dinsdag 31 augustus 2010

Retrieve label of EDT

How to get the label of an EDT?

See \Classes\DialogField\init
setting the label:
o.label(dictType.label(f));
with the dictType being:
dictType = new DictType(xtype);
and xtype being:
xtype = type >> 16;


Why do we have to right shift 16?
see \Classes\SysDictField\new
there you find a left shift 16
and global::fieldExt2Id does:
return (fieldExtId & 0xffff);

Also see http://www.eggheadcafe.com/software/aspnet/29515376/addfield-parameters.aspx
exerpt:
typeid() function gives you the id of a type. For eg:
you can try the following code in a job:
static void job1()
{;
print typeid(custAccount);
pause;
}
This will print out 6488075. In the AOT if you check up the ID of CustAcount
it is 99. But the above number that get from typeid function is a
combination of the ID in the AOT and the flag indicating that it is a user
type. The upper 16 bits contain the ID from the AOT (99)and the lower 16
bits contain the flag that it is a user type (11)
6488705 == (99 << 16 | 11)


Example:
public boolean validate(Object calledFrom)
{
    boolean ret;
    ToDate todate;
    dictType dictTypeLocal;
    ;


    ret = super(calledFrom);


    if (!toDate)
    {
        dictTypeLocal = new dictType(typeId(todate) >> 16);
        ret = checkfailed (strfmt("@SYS110217", dictTypeLocal.label()));


    }
    return ret;
}


Example - short version:
static void Job8(Args _args)
{
;
info(new dictType(typeId(ToDate) >> 16).label());
}



In Global Class:
public static LabelString aduTypeLabel(extendedTypeId _typeId)

{
;
return new dictType(_typeId >> 16).label();
}


Also (this example is a static method on ConfigTable):
static FieldLabel aduLabel()

{
;
return new SysDictType(extendedtypenum(ConfigId)).label();
}

modifiedField - previous value

Source: http://efreedom.com/Question/1-209764/Get-Previous-Field-Value-ModifiedField-Method-Dynamic-Ax-Table

Q: I would like to be able to perform some logic in the table.modifiedField method which compares the previous value of a field to the new value. How do I get to the previous value?

A: The record buffer as it was before any modifications is available through the this.orig() method.

Example:
public void modifiedField(fieldId _fieldId)

{
    super(_fieldId);
    info(strfmt("Field number %1 changed from %2 to %3",_fieldId,this.orig().(_fieldId),this.(_fieldId)));
}

donderdag 26 augustus 2010

How to create a production order with x++

Source: http://www.eggheadcafe.com/software/aspnet/31983659/how-to-create-a-production-order-with-x.aspx


static void CreateProductionOrder(Args _args)
{
ProdQtySched productionQty = 1;
ItemId productionItem = "AKU-1000";


ProdTable prodTable;
InventTable inventTable;
;
inventTable = InventTable::find(productionItem);


//Initialise the base values
prodTable.initValue();
prodTable.ItemId = inventTable.ItemId;
prodTable.initFromInventTable(inventTable);


prodTable.DlvDate = today();


prodTable.QtySched = productionQty;
prodTable.RemainInventPhysical = prodTable.QtySched;


//Set the active bom and route
prodTable.BOMId = BOMVersion::findActive(prodTable.ItemId,
prodTable.BOMDate,
prodTable.QtySched).BOMId;
prodTable.RouteId = RouteVersion::findActive(prodTable.ItemId,
prodTable.BOMDate,
prodTable.QtySched).RouteId;


prodTable.initRouteVersion();
prodTable.initBOMVersion();


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

The code above set the active BOM / Route and also creates the InventTrans
data.

woensdag 25 augustus 2010

Form layout - Dropdown with descriptive field

How to properly layout a dropdown and an accompanying descriptive field.
Like this:




Example while creating an item:



This is how the AOT looks like:















































And this is how to set the properties on the group that contains the dropdown and its descriptive field:

vrijdag 20 augustus 2010

InventOnHand vs InventDimOnHand

See: http://www.dynamicsaxtraining.com/tips-tricks/inventonhand-vs-inventdimonhand

Axapta InventOnHand class is wrapper for InventSum table. Unique index for InventSum table is ItemId + InventDimId. In other word, this class is used to get on hand for item with specific dimension. For example, if you require getting on-hand qty for “Bottle” items that have “green” color, “standard” size and are stored in “22” warehouse, “1” Aisle, “4” Shelf then you use InventOnHand class.

But, if you require getting on-hand qty for warehouse location then InventOnHand class couldn’t help us. Because one location could contains different items. Or if you require get on-hand qty for pallet. In these cases InventDimOnHand class must be used. This class is used when you require on-hand qty for specific inventDim. InventDimOnHand сlass consists of InventDimOnHandMember classes. Each InventDimOnHandMember class contains information about Item, Dimensions and Qty

For example, see link.