Refer the below blog
Custom-lookup-for-dimensions-in-ax-2012-for-user-defined-dimensions
Custom-lookup-for-dimensions-in-ax-2012-for-user-defined-dimensions
Creates and shows a lookup form for the Enum field for the Document Type based on reference type. Ex: If reference type is Purchase, document type enum should only have options blank, Product receipt, Receipt list, registration. If reference type is Sales, document type enum should only have options blank, Packing slip, Picking list Refer the Quality Association form (Inventory and warehouse management > Setup >Quality Control > Quality Association) Form InventTestAssociationTable QualityOrderGeneration_M_edit_documentType:Lookup method which calls the inventTestAssociationTable.lookupDocumentType(this); edit method on table is used to show the enum values.
Create a new notepad and add the below commands and save the file as with .bat extention to run as batch job. cls del D:\Test\TstLabel.axmodel cd /D D:\Program Files\Microsoft Dynamics AX\60\ManagementUtilities axutil export /model:"TST" /file:"D:\Test\TstLabel" /config:"Dynax_SIS" axutil import /file:"D:\Test\TstLabel" /config:"Dynax_SIS" /noPrompt Pause The 1st command clears the screen. The 2nd command is used delete the file if the file already exists where we want to export the file. The 3rd command will change the directory to where the Ax util tool is available. Check the path and ensure it is set to write file path. The 4th command will export the model "tst" to the file path mentioned from the configuration file (AOS server). The 5th command will import the file to desired configuration (AOS server). Ensure the required model is available in the new AOS configuration. Also modal will be imported to the same layer as it was exported. The 6th command will wait for user for user to press any key. This will help to check whether the export and import executed successfully.
static void HKS_defaultSODimension(Args _args)
{
DimensionAttribute dimensionAttribute;
DimensionAttributeValue dimAttributeValue;
DimensionAttributeValueSetStorage dimensionAttributeValueSetStorage;
DimensionAttributeValueSetItem dimensionAttributeValueSetItem;
DimensionAttributeValueSet dimAttrValueSet; //Stores the Hash value based on the combination of Atttibutes values. If no record found, new record is created.
SalesTable salesTable;
recId defaultDim;
TableId viewId;
viewId = tableNum("DimAttributeSalesTable");
select firstonly dimensionAttribute where dimensionAttribute.BackingEntityType == viewId;
//dimensionAttribute = DimensionAttribute::findByName("VendorGroup"); //find the attribute table.
dimAttributeValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimensionAttribute,"20",false,true); //get the Attribute value table. If the value is not found create a new one.
salesTable = salesTable::find("SO-100605");
dimensionAttributeValueSetStorage = dimensionAttributeValueSetStorage::find(salesTable.DefaultDimension);
//if ( !dimensionAttributeValueSetStorage.getDisplayValueByDimensionAttribute(dimensionAttribute.RecId))
if (dimAttributeValue) //Check if the attribute value is valid.
{
//checkif the attribute value is already exisitng as part of hash value in dimensionAttributeValueSetStorage
if (!dimensionAttributeValueSetStorage.containsDimensionAttributeValue(dimAttributeValue.RecId))
{
dimensionAttributeValueSetStorage.addItem(dimAttributeValue);
defaultDim = dimensionAttributeValueSetStorage.save();
update_recordSet salesTable setting DefaultDimension = defaultDim where salesTable.SalesId == "SO-100605"; //update the reference dimension.
}
}
}
while select sum(PostedQty),sum(Received),sum(Deducted), sum(Registered),sum(Picked) from inventSum group by itemId
where inventSum.ItemId == _itemId && inventSum.Closed == NoYes::No
join inventDim group by InventSiteId, InventLocationId,wMSLocationId where
inventDim.inventDimId == inventSum.InventDimId
{
inventQtyPhysicalOnhand = inventSum.PostedQty + inventSum.Received - inventSum.Deducted + inventSum.Registered - inventSum.Picked;
}
static void hks_InventMovementJournalPosting(Args _args)
{
InventJournalTable inventJournalTable;
InventJournalTrans inventJournalTrans;
InventJournalTableData inventJournalTableData;
InventJournalTransData inventJournalTransData;
InventTable inventTable;
InventDim inventDim;
InventJournalCheckPost inventJournalCheckPost = new InventJournalCheckPost();
container ledgerDim;
;
inventJournalTableData = JournalTableData::newTable(inventJournalTable);
//Init Journal table
inventJournalTable.clear();
inventJournalTable.initValue();
inventJournalTable.JournalId = inventJournalTableData.nextJournalId();
inventJournalTable.JournalType = InventJournalType::Movement;
inventJournalTable.JournalNameId = inventJournalTableData.journalStatic().standardJournalNameId(inventJournalTable.JournalType);
inventJournalTableData.initFromJournalName(inventJournalTableData.journalStatic().findJournalName(inventJournalTable.JournalNameId));
inventJournalTable.insert();
//Init JournalTrans
inventJournalTransData = inventJournalTableData.journalStatic().newJournalTransData(inventJournalTrans,inventJournalTableData);
select firstonly inventTable where inventTable.ItemId == '1000';
inventJournalTrans.clear();
inventJournalTrans.initFromInventJournalTable(inventJournalTable);
inventJournalTrans.TransDate = systemdateget() + 1 div 2;
inventJournalTrans.initFromInventTable(inventTable, false, false, false);
inventJournalTrans.Qty = 10;
inventJournalTrans.CostAmount = 100;
//Dimensions
inventDim.InventLocationId = "21";
inventDim.InventSiteId = InventLocation::find(inventDim.InventLocationId).InventSiteId;
inventJournalTrans.InventDimId = inventDim::findOrCreate(inventDim).inventDimId;
//set the offset account
ledgerDim = ["Goodwill",'1110000'];
inventJournalTrans.LedgerDimension = AxdDimensionUtil::getLedgerAccountId(ledgerDim);
inventJournalTransData.create();
if (InventJournalCheckPost::newPostJournal(inventJournalTable).validate())
InventJournalCheckPost::newPostJournal(inventJournalTable).run();
info (inventJournalTable.JournalId);
}