dinsdag 31 augustus 2010

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.

donderdag 12 augustus 2010

Brief description of ways to close a form in AX

See http://kashperuk.blogspot.com/2010/07/tutorial-brief-description-of-ways-to.html

There are “only” 5 ways to close a form:
  • Close - close the form. Similar to the 'X' button.
  • CloseOK – close the form, and set the OK flag – called by the Commandbutton::Ok
  • CloseCancel – close the form, and set the Cancel flag – called by the Commandbutton::Cancel
  • CloseSelectRecord – close the lookup form, and set return record
  • CloseSelect – close the lookup form, and set return value
The below methods (note their names are in past-tense) are used to determine if or how a form was closed:
  • Closed – Returns true, if the form is no longer open
  • ClosedOK – Return true, if the form was closed by the user clicking ‘OK’
  • ClosedCancel – Returns true, if the form was closed by the user clicking ‘Cancel’
Finally, CanClose() is called before any of the close methods get called. If CanClose() returns false, the form is not allowed to close.